本文整理汇总了C++中LOG2函数的典型用法代码示例。如果您正苦于以下问题:C++ LOG2函数的具体用法?C++ LOG2怎么用?C++ LOG2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LOG2函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ifs
bool Inventory::readRecipe(const std::string& recipeFile)
{
std::ifstream ifs(recipeFile.c_str());
if (ifs.fail())
{
LOG2(ERROR, "Could not find: " + recipeFile);
ifs.close();
return false;
}
//LOG(INFO, "Inventory", "Reading: " + recipeFile);
std::string temp;
int height = 0, width = 0, outCount = 0;
int16_t outType = 0, outHealth = 0;
// Reading row at a time
int del;
bool readingRecipe = false;
std::vector<std::string> line;
std::vector<ItemPtr> recipetable;
std::string text;
while (getline(ifs, temp))
{
//If empty line
if (temp.empty())
{
continue;
}
// If commentline -> skip to next
if (temp[0] == COMMENTPREFIX)
{
continue;
}
// Init vars
del = 0;
line.clear();
// Process line
while (!temp.empty())
{
// Remove white spaces
while (temp[0] == ' ')
{
temp = temp.substr(1);
}
// Split words
del = temp.find(' ');
if (del > -1)
{
line.push_back(temp.substr(0, del));
temp = temp.substr(del + 1);
}
else
{
line.push_back(temp);
break;
}
}
// Begin recipe
if (line.size() == 1 && line[0] == "<-")
{
readingRecipe = true;
continue;
}
// Begin recipe
if (line.size() == 1 && line[0] == "->")
{
readingRecipe = false;
continue;
}
if (readingRecipe)
{
for (unsigned int i = 0; i < line.size(); i++)
{
std::string data(line[i]);
ItemPtr item(new Item);
item->setCount(1);
item->setHealth(-1);
int location = data.find("x");
if (location > -1)
{
// Quantity before ID
item->setCount(atoi(data.substr(0, location).c_str()));
data = data.substr(location + 1, std::string::npos);
}
location = data.find(":");
if (location > -1)
{
// Meta after ID
item->setHealth(atoi(data.substr(location + 1, std::string::npos).c_str()));
data = data.substr(0, location);
}
//.........这里部分代码省略.........
示例2: ASSERT
//---------------------------------------------------------------------------
//
// バイト書き込み
//
//---------------------------------------------------------------------------
void FASTCALL CRTC::WriteByte(uint32_t addr, uint32_t data)
{
int reg;
ASSERT(this);
ASSERT((addr >= memdev.first) && (addr <= memdev.last));
// $800単位でループ
addr &= 0x7ff;
// ウェイト
scheduler->Wait(1);
// $E80000-$E803FF : レジスタエリア
if (addr < 0x400) {
addr &= 0x3f;
if (addr >= 0x30) {
return;
}
// 書き込み(エンディアンを反転させる)
addr ^= 1;
if (crtc.reg[addr] == data) {
return;
}
crtc.reg[addr] = (uint8_t)data;
// GVRAMアドレス構成
if (addr == 0x29) {
if (data & 0x10) {
crtc.tmem = TRUE;
}
else {
crtc.tmem = FALSE;
}
if (data & 0x08) {
crtc.gmem = TRUE;
}
else {
crtc.gmem = FALSE;
}
crtc.siz = (data & 4) >> 2;
crtc.col = (data & 3);
// グラフィックVRAMへ通知
gvram->SetType(data & 0x0f);
return;
}
// 解像度変更
if ((addr <= 15) || (addr == 40)) {
// スプライトメモリの接続・切断は瞬時に行う(OS-9/68000)
if (addr == 0x28) {
if ((crtc.reg[0x28] & 3) >= 2) {
sprite->Connect(FALSE);
}
else {
sprite->Connect(TRUE);
}
}
// 次の周期で再計算
crtc.changed = TRUE;
return;
}
// ラスタ割り込み
if ((addr == 18) || (addr == 19)) {
crtc.raster_int = (crtc.reg[19] << 8) + crtc.reg[18];
crtc.raster_int &= 0x3ff;
CheckRaster();
return;
}
// テキストスクロール
if ((addr >= 20) && (addr <= 23)) {
crtc.text_scrlx = (crtc.reg[21] << 8) + crtc.reg[20];
crtc.text_scrlx &= 0x3ff;
crtc.text_scrly = (crtc.reg[23] << 8) + crtc.reg[22];
crtc.text_scrly &= 0x3ff;
render->TextScrl(crtc.text_scrlx, crtc.text_scrly);
CRTC_LOG(LOG2(Log::Normal, "テキストスクロール x=%d y=%d", crtc.text_scrlx, crtc.text_scrly));
return;
}
// グラフィックスクロール
if ((addr >= 24) && (addr <= 39)) {
reg = addr & ~3;
addr -= 24;
addr >>= 2;
ASSERT(addr <= 3);
crtc.grp_scrlx[addr] = (crtc.reg[reg+1] << 8) + crtc.reg[reg+0];
crtc.grp_scrly[addr] = (crtc.reg[reg+3] << 8) + crtc.reg[reg+2];
if (addr == 0) {
//.........这里部分代码省略.........
示例3: LOG2
///询价通知
void CMdSpi::OnRtnForQuoteRsp(CThostFtdcForQuoteRspField *pForQuoteRsp)
{
LOG2("Subscribed Quote Response for InstrmentID: ", pForQuoteRsp->InstrumentID);
}
示例4: freeSpace
TWmDrmStoreState CWmDrmDataStore::DataStoreStateL()
{
TWmDrmStoreState state;
TInt64 freeSpace( 0 );
TInt64 freeSpace2( 0 );
TInt dataStoreSize( 0 );
TInt dummyDbSize( 0 );
TInt ratio( 0 );
TInt ratio2( 0 );
TBool internalMassDriveNotFull( ETrue );
LOGFN( "CWmDrmDataStore::DataStoreStateL" );
freeSpace = iServer->FreeSpaceL( EFalse );
if ( iWmDrmRightsConfigFound )
{
// Check free space from the configured drive, too.
freeSpace2 = iServer->FreeSpaceL( ETrue );
if ( freeSpace2 < iMinFreeSpace2 )
{
internalMassDriveNotFull = EFalse;
}
dummyDbSize = DummyDBSizeL( ETrue );
dataStoreSize = DataStoreSizeL( ETrue );
ratio2 = dataStoreSize * 100 / iInitialFreeSpace2;
freeSpace2 += dummyDbSize;
#ifdef _LOGGING
TBuf<KMaxTInt64BufLength> free2;
LOG1( "CWmDrmDataStore::DataStoreStateL: Free space (2): ");
free2.AppendNumUC( freeSpace2, EDecimal );
LOG( free2 );
TBuf<KMaxTInt64BufLength> free2Min;
LOG1( "CWmDrmDataStore::DataStoreStateL: Minimum free space (2): ");
free2Min.AppendNumUC( iMinFreeSpace2, EDecimal );
LOG( free2Min );
#endif
}
// Check the system drive storage space next.
dummyDbSize = DummyDBSizeL( EFalse );
dataStoreSize = DataStoreSizeL( EFalse );
ratio = dataStoreSize * 100 / iInitialFreeSpace;
freeSpace += dummyDbSize;
#ifdef _LOGGING
TBuf<KMaxTInt64BufLength> free;
LOG1( "CWmDrmDataStore::DataStoreStateL: Free space: ");
free.AppendNumUC( freeSpace, EDecimal );
LOG( free );
TBuf<KMaxTInt64BufLength> freeMin;
LOG1( "CWmDrmDataStore::DataStoreStateL: Minimum free space: ");
freeMin.AppendNumUC( iMinFreeSpace, EDecimal );
LOG( freeMin );
#endif
// Select the state of the storage space.
if ( ( freeSpace > iMinFreeSpace ) && internalMassDriveNotFull )
{
LOG1( "CWmDrmDataStore::DataStoreStateL: Store space Ok" );
state = EStoreSpaceOK;
}
else
{
// The configured drive is running out of space. The system drive
// may also be running out of storage space, but calculate
// the ratio of database size to initial free drive space and the
// state of the drive storage space from the configured drive because
// it is likely to fill up faster since the media files may be synced to it.
if ( !internalMassDriveNotFull )
{
LOG2( "Ratio (2): %d", ratio2 );
if ( ratio2 <= iMaxSpaceRatio2 )
{
LOG1( "CWmDrmDataStore::DataStoreStateL: Store space low (2)" );
state = EStoreSpaceLow;
}
else
{
LOG1( "CWmDrmDataStore::DataStoreStateL: Store space full (2)" );
state = EStoreSpaceFull;
}
}
else
// Only the system drive is running out of storage space.
{
LOG2( "Ratio: %d", ratio );
if ( ratio <= iMaxSpaceRatio )
{
LOG1( "CWmDrmDataStore::DataStoreStateL Store space low" );
state = EStoreSpaceLow;
}
else
{
LOG1( "CWmDrmDataStore::DataStoreStateL Store space full" );
state = EStoreSpaceFull;
}
}
}
//.........这里部分代码省略.........
示例5: get_pool
int get_pool() { return LOG2(ItemSize)-4; }
示例6: if
void apollo_kbd_device::mouse::read_mouse()
{
if (m_tx_pending > 0)
{
m_tx_pending -= 5; // we will be called every 5ms
}
else
{
int b = m_device->m_io_mouse1->read();
int x = m_device->m_io_mouse2->read();
int y = m_device->m_io_mouse3->read();
/* sign extend values < 0 */
if (x & 0x80)
x |= 0xffffff00;
if (y & 0x80)
y |= 0xffffff00;
y = -y;
if (m_last_b < 0)
{
m_last_b = b;
m_last_x = x;
m_last_y = y;
}
else if (b != m_last_b || x != m_last_x || y != m_last_y)
{
UINT8 mouse_data[4];
int mouse_data_size;
int dx = x - m_last_x;
int dy = y - m_last_y;
LOG2(("read_mouse: b=%02x x=%d y=%d dx=%d dy=%d", b, x, y, dx, dy));
if (m_device->m_mode == KBD_MODE_0_COMPATIBILITY)
{
mouse_data[0] = 0xdf;
mouse_data[1] = 0xf0 ^ b;
mouse_data[2] = dx;
mouse_data[3] = dy;
mouse_data_size = 4;
}
else
{
if (m_device->m_mode != KBD_MODE_2_RELATIVE_CURSOR_CONTROL)
{
m_device->set_mode(KBD_MODE_2_RELATIVE_CURSOR_CONTROL);
}
mouse_data[0] = 0xf0 ^ b;
mouse_data[1] = dx;
mouse_data[2] = dy;
mouse_data_size = 3;
}
for (int md = 0; md < mouse_data_size; md++)
{
m_device->xmit_char(mouse_data[md]);
}
// mouse data submitted; update current mouse state
m_last_b = b;
m_last_x += dx;
m_last_y += dy;
m_tx_pending = 100; // mouse data packet will take 40 ms
}
}
}
示例7: blk_get_device_part_str
//.........这里部分代码省略.........
* Less than whole string converted,
* or request for whole device, but caller requires partition.
*/
if (*ep || (part == 0 && !allow_whole_dev)) {
printf("** Bad partition specification %s %s **\n",
ifname, dev_part_str);
goto cleanup;
}
}
/*
* No partition table on device,
* or user requested partition 0 (entire device).
*/
if (((*dev_desc)->part_type == PART_TYPE_UNKNOWN) ||
(part == 0)) {
if (!(*dev_desc)->lba) {
printf("** Bad device size - %s %s **\n", ifname,
dev_str);
goto cleanup;
}
/*
* If user specified a partition ID other than 0,
* or the calling command only accepts partitions,
* it's an error.
*/
if ((part > 0) || (!allow_whole_dev)) {
printf("** No partition table - %s %s **\n", ifname,
dev_str);
goto cleanup;
}
(*dev_desc)->log2blksz = LOG2((*dev_desc)->blksz);
part_get_info_whole_disk(*dev_desc, info);
ret = 0;
goto cleanup;
}
/*
* Now there's known to be a partition table,
* not specifying a partition means to pick partition 1.
*/
if (part == PART_UNSPECIFIED)
part = 1;
/*
* If user didn't specify a partition number, or did specify something
* other than "auto", use that partition number directly.
*/
if (part != PART_AUTO) {
ret = part_get_info(*dev_desc, part, info);
if (ret) {
printf("** Invalid partition %d **\n", part);
goto cleanup;
}
} else {
/*
* Find the first bootable partition.
* If none are bootable, fall back to the first valid partition.
*/
part = 0;
for (p = 1; p <= MAX_SEARCH_PARTITIONS; p++) {
ret = part_get_info(*dev_desc, p, info);
示例8: clear_sense_data
static void clear_sense_data(omti8621_state *state) {
LOG2(("clear_sense_data"));
memset(state->sense_data, 0, sizeof(state->sense_data));
}
示例9: LOG2
void FaceDetector::skinTypeDetect(ia_frame *frame)
{
LOG2("@%s", __FUNCTION__);
Mutex::Autolock lock(mLock);
ia_face_detect_skin(mContext, frame);
}
示例10: LOG
void CMMADisplay::SourceSizeChanged(const TSize& aSourceSize)
{
LOG(EJavaMMAPI,EInfo,"CMMADisplay::SourceSizeChanged");
#ifdef RD_JAVA_NGA_ENABLED
if (iWindow)
{
iWindow->SetVideoCropRegion(TRect(iUserRect.iTl, aSourceSize));
}
#endif
iSourceSize = aSourceSize;
LOG1(EJavaMMAPI,EInfo,"MMA::CMMADisplay::SourceSizeChanged %d",
aSourceSize.iWidth);
LOG1(EJavaMMAPI,EInfo,"MMA::CMMADisplay::SourceSizeChanged %d",
aSourceSize.iHeight);
jmethodID getDisplayWidthID = iJni->GetMethodID(
iJavaDisplayClass,
"getDisplayWidth",
"()I");
jmethodID getDisplayHeightID = iJni->GetMethodID(
iJavaDisplayClass,
"getDisplayHeight",
"()I");
TInt x = iJni->CallIntMethod(iJavaDisplayObject,getDisplayWidthID);
TInt y = iJni->CallIntMethod(iJavaDisplayObject,getDisplayHeightID);
LOG2(EJavaMMAPI,EInfo,"CMMADisplay.cpp : SourceSizeChanged () iFullScreenSize is x = %d ,y = %d ",x,y);
// get the ScreenSize from canvas in java
TSize canvasSize(x, y);
iFullScreenSize = canvasSize;
TBool sourceIsBigger = (aSourceSize.iWidth > iFullScreenSize.iWidth ||
aSourceSize.iHeight > iFullScreenSize.iHeight);
if (sourceIsBigger)
{
// Source is larger than display area.
// Shrink draw are to fit in display.
iWindow->SetDrawRect(ScaleToFullScreen(iFullScreenSize, iSourceSize));
}
else
{
// source is smaller than display area
iWindow->SetDrawRect(TRect(iUserRect.iTl, iSourceSize));
}
SetClippingRegion();
if (iUserRect.IsEmpty())
{
// Java side hasn't set size.
iUserRect = iWindow->DrawRect();
if (!sourceIsBigger)
{
// Addjusting rect to top left corner.
iUserRect = TRect(iUserRect.Size());
}
}
}
示例11: set_interrupt
static void set_interrupt(const omti8621_state *state, enum line_state line_state) {
if (state->irq_handler != NULL) {
LOG2(("set_interrupt: status_port=%x", state->status_port));
(*state->irq_handler)(&state->device->machine(), line_state);
}
}
示例12: kernelOuter
bool DiffOfGaussianKernel<T, U>::Initialize_()
{
//if (m_dimension<5) return false;
// create two gaussian deriv kernels
PGCore::GaussianKernel<T, U> kernelOuter(m_sigmaOuter, m_dimension);
PGCore::GaussianKernel<T, U> kernelInner(m_sigmaInner, m_dimension);
kernelOuter-= kernelInner;
memcpy(m_buffer, kernelOuter.GetBuffer(), m_dimension*sizeof(float));
for(int i=0;i<(m_dimension);i++)
{
m_buffer[i]*=10;//m_dimension;
}
/*
float sum=0;
for(int i=0;i<(m_dimension);i++)
{
m_buffer[i]*=50;//m_dimension;
sum += m_buffer[i];
}
if (sum<0)
{
float offset=abs(sum)/m_dimension;
for (int i=0; i<(m_dimension); i++)
{
m_buffer[i] = offset;
}
}
*/
#ifdef _DEBUG
LOG0("{ The filter coefficients difference of gaussian are:");
for(int i=0;i<(m_dimension);i++)
{
LOG2("Kernel[%d] = %f", i, (double)m_buffer[i]);
}
LOG0("} The filter coefficients.");
#endif
//Reset()
// experimental
// 0 -1 -2 -1 0
// -1 -2 -4 -2 1
// -2 -4 0 4 2
// -1 2 4 2 1
// 0 1 2 1 0
/*
if (!m_orientY)
{
// fill up the buffer here
SetValue(1, 0, (T)(-1.0f)); SetValue(3, 0, (T)(-1.0f));
SetValue(1, 1, (T)(-2.0f)); SetValue(3, 1, (T)(-2.0f));
SetValue(1, 3, (T)(2.0f)); SetValue(3, 3, (T)(2.0f));
SetValue(1, 4, (T)(1.0f)); SetValue(3, 4, (T)(1.0f));
SetValue(2, 0, (T)(-2.0f));
SetValue(2, 1, (T)(-4.0f));
SetValue(2, 3, (T)(4.0f));
SetValue(2, 4, (T)(2.0f));
} else
{
// fill up the buffer here
SetValue(0, 1, (T)(-1.0f)); SetValue(0, 3, (T)(-1.0f));
SetValue(1, 1, (T)(-2.0f)); SetValue(1, 3, (T)(-2.0f));
SetValue(3, 1, (T)(2.0f)); SetValue(3, 3, (T)(2.0f));
SetValue(4, 1, (T)(1.0f)); SetValue(4, 3, (T)(1.0f));
SetValue(0, 2, (T)(-2.0f));
SetValue(1, 2, (T)(-4.0f));
SetValue(3, 2, (T)(4.0f));
SetValue(4, 2, (T)(2.0f));
}*/
return true;
}
示例13: client_callback
void client_callback(int fd,
short ev,
void* arg)
{
User* user = (User*)arg;
/*
std::vector<User *>::const_iterator it = std::find (Mineserver::get()->users().begin(),
Mineserver::get()->users().end(), user);
if(it == Mineserver::get()->users().end())
{
LOG2(INFO, "Using dead player!!!");
return;
}
*/
if (ev & EV_READ)
{
int read = 1;
uint8_t* buf = new uint8_t[2048];
read = recv(fd, (char*)buf, 2048, 0);
if (read == 0)
{
LOG2(INFO, "Socket closed properly");
delete user;
user = (User*)1;
delete[] buf;
return;
}
if (read == SOCKET_ERROR)
{
LOG2(INFO, "Socket had no data to read");
delete user;
user = (User*)2;
delete[] buf;
return;
}
user->lastData = time(NULL);
user->buffer.addToRead(buf, read);
delete[] buf;
user->buffer.reset();
while (user->buffer >> (int8_t&)user->action)
{
//Variable len package
if (Mineserver::get()->packetHandler()->packets[user->action].len == PACKET_VARIABLE_LEN)
{
//Call specific function
int (PacketHandler::*function)(User*) =
Mineserver::get()->packetHandler()->packets[user->action].function;
bool disconnecting = user->action == 0xFF;
int curpos = (Mineserver::get()->packetHandler()->*function)(user);
if (curpos == PACKET_NEED_MORE_DATA)
{
user->waitForData = true;
event_set(user->GetEvent(), fd, EV_READ, client_callback, user);
event_add(user->GetEvent(), NULL);
return;
}
if (disconnecting) // disconnect -- player gone
{
delete user;
user = (User*)4;
return;
}
}
else if (Mineserver::get()->packetHandler()->packets[user->action].len == PACKET_DOES_NOT_EXIST)
{
std::ostringstream str;
str << "Unknown action: 0x" << std::hex << user->action;
LOG2(DEBUG, str.str());
delete user;
user = (User*)3;
return;
}
else
{
if (!user->buffer.haveData(Mineserver::get()->packetHandler()->packets[user->action].len))
{
user->waitForData = true;
event_set(user->GetEvent(), fd, EV_READ, client_callback, user);
event_add(user->GetEvent(), NULL);
return;
}
//Call specific function
int (PacketHandler::*function)(User*) = Mineserver::get()->packetHandler()->packets[user->action].function;
(Mineserver::get()->packetHandler()->*function)(user);
}
} //End while
//.........这里部分代码省略.........
示例14: switch
bool Inventory::canBeArmour(int slot, int type)
{
if (slot == 5)
{
// Helmet slot. Lots of fun here
if (ServerInstance->m_only_helmets)
{
switch (type)
{
case ITEM_LEATHER_HELMET:
case ITEM_CHAINMAIL_HELMET:
case ITEM_IRON_HELMET:
case ITEM_DIAMOND_HELMET:
case ITEM_GOLD_HELMET:
return true;
break;
}
return false;
}
else
{
return true;
}
}
else if (slot == 6)
{
switch (type)
{
case ITEM_LEATHER_CHESTPLATE:
case ITEM_CHAINMAIL_CHESTPLATE:
case ITEM_IRON_CHESTPLATE:
case ITEM_DIAMOND_CHESTPLATE:
case ITEM_GOLD_CHESTPLATE:
return true;
break;
}
return false;
}
else if (slot == 7)
{
switch (type)
{
case ITEM_LEATHER_LEGGINGS:
case ITEM_CHAINMAIL_LEGGINGS:
case ITEM_IRON_LEGGINGS:
case ITEM_DIAMOND_LEGGINGS:
case ITEM_GOLD_LEGGINGS:
return true;
break;
}
return false;
}
else if (slot == 8)
{
switch (type)
{
case ITEM_LEATHER_BOOTS:
case ITEM_CHAINMAIL_BOOTS:
case ITEM_IRON_BOOTS:
case ITEM_DIAMOND_BOOTS:
case ITEM_GOLD_BOOTS:
return true;
break;
}
return false;
}
LOG2(WARNING, "Unknown armour slot.");
return false;
}
示例15: LOG2
void apollo_kbd_device::beeper::reset()
{
LOG2(("reset apollo_kbd::beeper"));
on();
}