Ejemplo n.º 1
0
void addCategoryToObject( int inObjectID, int inParentID ) {

    if( getCategory( inParentID ) == NULL ) {
        addCategory( inParentID );
        }

    if( inObjectID >= reverseMapSize ) {
        // expand map

        int newMapSize = inObjectID + 1;
        
        ReverseCategoryRecord **newMap = new ReverseCategoryRecord*[newMapSize];
        
        for( int i=0; i<newMapSize; i++ ) {
            newMap[i] = NULL;
            }

        memcpy( newMap, reverseMap, 
                sizeof(ReverseCategoryRecord*) * reverseMapSize );

        delete [] reverseMap;
        reverseMap = newMap;
        reverseMapSize = newMapSize;
        }
    
    
    CategoryRecord *r = getCategory( inParentID );
    
    if( r != NULL ) {

        for( int i=0; i< r->objectIDSet.size(); i++ ) {
            if( r->objectIDSet.getElementDirect( i ) == inObjectID ) {
                // already there
                return;
                }
            }

        r->objectIDSet.push_back( inObjectID );
        r->objectWeights.push_back( 0.0f );
        autoAdjustWeights( inParentID );
        
        ReverseCategoryRecord *rr = getReverseCategory( inObjectID );

        
        if( rr == NULL ) {
            rr = new ReverseCategoryRecord;

            rr->childID = inObjectID;
            
            reverseMap[ inObjectID ] = rr;        
            }
        
        rr->categoryIDSet.push_back( inParentID );

        saveCategoryToDisk( inParentID );
        }
    
    }
void EventLogChannel::log(const Message& msg)
{
	if (!_h) open();
#if defined(POCO_WIN32_UTF8)
	std::wstring utext;
	UnicodeConverter::toUTF16(msg.getText(), utext);
	const wchar_t* pMsg = utext.c_str();
	ReportEventW(_h, getType(msg), getCategory(msg), POCO_MSG_LOG, NULL, 1, 0, &pMsg, NULL); 
#else
	const char* pMsg = msg.getText().c_str();
	ReportEvent(_h, getType(msg), getCategory(msg), POCO_MSG_LOG, NULL, 1, 0, &pMsg, NULL); 
#endif
}
Ejemplo n.º 3
0
void removeObjectFromAllCategories( int inObjectID ) {
    ReverseCategoryRecord *rr = getReverseCategory( inObjectID );
        
    if( rr != NULL ) {    
            
        for( int i=0; i< rr->categoryIDSet.size(); i++ ) {
                
            int cID = rr->categoryIDSet.getElementDirect( i );
            
            CategoryRecord *r = getCategory( cID );
                
            if( r != NULL ) {
                int index = r->objectIDSet.getElementIndex( inObjectID );
                
                if( index != -1 ) {
                    r->objectIDSet.deleteElement( index );
                    r->objectWeights.deleteElement( index );
                    }
                
                saveCategoryToDisk( cID );
                }
            }
            
        delete rr;
            
        reverseMap[ inObjectID ] = NULL;
        }
    }
Ejemplo n.º 4
0
void removeCategoryFromObject( int inObjectID, int inParentID ) {
    CategoryRecord *r = getCategory( inParentID );
    
    if( r != NULL ) {

        int index = r->objectIDSet.getElementIndex( inObjectID );
        
        if( index != -1 ) {
            r->objectIDSet.deleteElement( index );
            r->objectWeights.deleteElement( index );
            }

        autoAdjustWeights( inParentID );
        

        ReverseCategoryRecord *rr = getReverseCategory( inObjectID );
        
        if( rr != NULL ) {    
            rr->categoryIDSet.deleteElementEqualTo( inParentID );
            }
            
        saveCategoryToDisk( inParentID );
        }

    }
Ejemplo n.º 5
0
void fullCombination(const bool electrons = false)
{
  TString type("_muons");
  if( electrons ) type = "_electrons";

  std::map<TString, TList*> cathegories;
  // Loop over all files
  std::map<TString, double> fw(filesAndWeightsMap( electrons ));
  std::map<TString, double>::const_iterator it = fw.begin();
  for( ; it != fw.end(); ++it ) {
    TString cathegory(getCategory(it->first));
    if( cathegories[cathegory] == 0 ) cathegories[cathegory] = new TList();
    std::cout << "fileName = " << std::string(it->first).substr(std::string(it->first).find_last_of("/")+1)+"weighted"+type+".root" << std::endl;
    cathegories[cathegory]->Add( TFile::Open(std::string(it->first).substr(std::string(it->first).find_last_of("/")+1)+"weighted"+type+".root") );
  }

  TList * combinationsList = new TList();
  std::map<TString, TList*>::const_iterator it2 = cathegories.begin();
  for( ; it2 != cathegories.end(); ++it2 ) {
    TFile *Target = TFile::Open( it2->first+"_combined"+type+".root", "RECREATE" );
    std::cout << "fileName = " << it2->first << std::endl;
    combinationsList->Add( Target );
    mergeFiles( Target, it2->second );
  }
}
Ejemplo n.º 6
0
/*
 * Class:     org_apache_log4j_nt_NTEventLogAppender
 * Method:    reportEvent
 * Signature: (ILjava/lang/String;I)V
 */
JNIEXPORT void JNICALL Java_org_apache_log4j_nt_NTEventLogAppender_reportEvent(
   JNIEnv *env, jobject java_this, jint handle, jstring jstr, jint priority) {
  
  jboolean localHandle = JNI_FALSE;
  if (handle == 0) {
    // Client didn't give us a handle so make a local one.
    handle = (jint)RegisterEventSource(NULL, "Log4j");
    localHandle = JNI_TRUE;
  }
  
  // convert Java String to character array
  const int numStrings = 1;
  LPCTSTR array[numStrings];
  char *nstr = JNU_GetStringNativeChars(env, jstr);
  array[0] = nstr;
  
  // This is the only message supported by the package. It is backed by
  // a message resource which consists of just '%1' which is replaced
  // by the string we just created.
  const DWORD messageID = 0x1000;
  ReportEvent((HANDLE)handle, getType(priority), 
	      getCategory(priority), 
	      messageID, NULL, 1, 0, array, NULL);
  
  free((void *)nstr);
  if (localHandle == JNI_TRUE) {
    // Created the handle here so free it here too.
    DeregisterEventSource((HANDLE)handle);
  }
  return;
}
Ejemplo n.º 7
0
void moveCategoryMemberDown( int inParentID, int inObjectID ) {

    CategoryRecord *r = getCategory( inParentID );
    
    if( r != NULL ) {        
        int index = r->objectIDSet.getElementIndex( inObjectID );
        
        if( index != -1 && 
            index != r->objectIDSet.size() - 1 ) {
            
            int *id = r->objectIDSet.getElement( index );
            int *idToSwapWith = r->objectIDSet.getElement( index + 1 );
            
            int temp = *idToSwapWith;            

            *idToSwapWith = *id;
            *id = temp;

            float *prob = r->objectWeights.getElement( index );
            float *probToSwapWith = r->objectWeights.getElement( index + 1 );

            float tempProb = *probToSwapWith;            

            *probToSwapWith = *prob;
            *prob = tempProb;

            saveCategoryToDisk( inParentID );
            }
        }
    }
Ejemplo n.º 8
0
void SceneNode::onCommand(const Command& command, sf::Time dt){
	if (command.category & getCategory())
		command.action(*this, dt);

	for (auto child = mChildren.begin(); child != mChildren.end(); ++child)
		(*child)->onCommand(command, dt);
}
Ejemplo n.º 9
0
void LLPanelClassifiedEdit::sendUpdate()
{
	LLAvatarClassifiedInfo c_data;

	if(getClassifiedId().isNull())
	{
		setClassifiedId(LLUUID::generateNewID());
	}

	c_data.agent_id = gAgent.getID();
	c_data.classified_id = getClassifiedId();
	// *HACK 
	// Categories on server start with 1 while combo-box index starts with 0
	c_data.category = getCategory() + 1;
	c_data.name = getClassifiedName();
	c_data.description = getDescription();
	c_data.parcel_id = getParcelId();
	c_data.snapshot_id = getSnapshotId();
	c_data.pos_global = getPosGlobal();
	c_data.flags = getFlags();
	c_data.price_for_listing = getPriceForListing();

	LLAvatarPropertiesProcessor::getInstance()->sendClassifiedInfoUpdate(&c_data);
	
	if(isNew())
	{
		// Lets assume there will be some error.
		// Successful sendClassifiedInfoUpdate will trigger processProperties and
		// let us know there was no error.
		mIsNewWithErrors = true;
	}
}
Ejemplo n.º 10
0
/*
 * Class:     org_apache_log4j_nt_NTEventLogAppender
 * Method:    reportEvent
 * Signature: (ILjava/lang/String;I)V
 */
JNIEXPORT void JNICALL Java_org_apache_log4j_nt_NTEventLogAppender_reportEvent(
   JNIEnv *env, jobject java_this, jint jhandle, jstring jstr, jint priority) {
  jboolean localHandle = JNI_FALSE;
  HANDLE handle = gEventSources.getHandle(jhandle);
  if (handle == 0) {
    // Client didn't give us a handle so make a local one.
    handle = RegisterEventSourceW(NULL, L"Log4j");
    localHandle = JNI_TRUE;
  }
  
  // convert Java String to character array
  jsize msgLen = env->GetStringLength(jstr);
  jchar* msg = (jchar*) malloc((msgLen + 1) * sizeof(jchar));
  env->GetStringRegion(jstr, 0, msgLen, msg);
  msg[msgLen] = 0;
  
  // This is the only message supported by the package. It is backed by
  // a message resource which consists of just '%1' which is replaced
  // by the string we just created.
  const DWORD messageID = 0x1000;
  ReportEventW(handle, getType(priority), 
	      getCategory(priority), 
	      messageID, NULL, 1, 0, (const wchar_t**) &msg, NULL);
  
  free((void *)msg);
  if (localHandle == JNI_TRUE) {
    // Created the handle here so free it here too.
    DeregisterEventSource(handle);
  }
  return;
}
Ejemplo n.º 11
0
void SceneNode::callCommand(const Command& command, sf::Time dt)
{
	if (command.category & getCategory())
		command.action(*this, dt);
	for (const Ptr& child : children)
		child->callCommand(command, dt);
}
Ejemplo n.º 12
0
bool DesignStore::addDesign(Design::Ptr d){
  d->setDesignId(next_designid++);

  //check components all come from this category
  IdMap cl = d->getComponents();
  Player::Ptr player = Game::getGame()->getPlayerManager()->getPlayer(d->getOwner());
  PlayerView::Ptr playerview = player->getPlayerView();
  for(IdMap::iterator itcurr = cl.begin(); 
      itcurr != cl.end(); ++itcurr){
    if(!(playerview->isUsableComponent(itcurr->first)))
      return false;
    std::map<uint32_t, Component::Ptr>::iterator itcomp = components.find(itcurr->first);
    if(itcomp == components.end())
      return false;
    getComponent(itcurr->first)->setInUse();
  }
  d->eval();
  designs[d->getId()] = d;
  getCategory(d->getCategoryId())->doAddDesign(d);

  if(d->isValid()){
    playerview->addUsableDesign(d->getId());
  }else{
    playerview->addVisibleDesign( DesignView::Ptr( new DesignView( d->getId(), true )) );
  }

  Game::getGame()->getPlayerManager()->updatePlayer(player->getID());
  Game::getGame()->getPersistence()->saveDesign(d);
  return true;
}
void NaiveBayesianClassifier::changeWordCount(const QString &category, const QString &word, int change)
{
    long idxsearch=-1;
    c4_Row findrow;
    c4_StringProp match("word");
    
    const char* test = word;
    match(findrow) = test;
    c4_IntProp count("count");

    c4_View cat = getCategory(category);

    idxsearch = cat.Find(findrow,idxsearch+1);

    if (idxsearch>=0) {
        long int zero = 0;
        count(cat[idxsearch]) = std::max(zero, count(cat[idxsearch]) + change);
    } 
    else 
    {
        c4_StringProp newWord("word");
        c4_IntProp newCount("count");
        c4_Row newRow;
        QString temp = QString(word);
        newWord(newRow)=temp;
        newCount(newRow)=1;
        cat.Add(newRow);
    }
}
Ejemplo n.º 14
0
char isProbabilitySet( int inParentID ) {
    CategoryRecord *r = getCategory( inParentID );
    if( r != NULL && r->isProbabilitySet ) { 
        return true;
        }
    return false;
    }
Ejemplo n.º 15
0
void EPropertySheet::addProperty ( const char* categoryName, const char* propName, EPropertyVar* propVar )
{
    QStandardItem* categoryItem = getCategory ( categoryName );
    int curRow = 0;
    if ( !categoryItem )
    {
        curRow = mTreeModel->rowCount();
        mTreeModel->setRowCount ( curRow + 1 );
        categoryItem = new QStandardItem ( categoryName );
        mTreeModel->setItem ( curRow, 0, categoryItem );
        categoryItem->setEditable ( false );
        mTreeView->expand ( categoryItem->index() );
    }

    QList<QStandardItem*> lists;
    EPropertySheetTreeItem* item  = new EPropertySheetTreeItem ( propName );
    item->setBackground ( QBrush ( Qt::lightGray ) );
    item->setEditable ( false );
    lists.push_back ( item );

    item  = new EPropertySheetTreeItem();
    item->SetExtraData ( propVar );
    QVariant var;
    toQVariant ( propVar->mProp, var );
    item->setData ( var, Qt::EditRole );
	//item->setWhatsThis("WhatsThis");
	//item->setStatusTip("StatusTip");
	item->setToolTip("ToolTip");
    //item->setData ( Qt::EditRole ,var);
    lists.push_back ( item );

    categoryItem->appendRow ( lists );
}
Ejemplo n.º 16
0
void AddTaskDialog::construct()
{
    ++obj_cnt;
    upd_mode = false;
    additional_flag = false;
    setAttribute(Qt::WA_DeleteOnClose);
    setWindowTitle("REXLoader - "+tr("Новое задание"));
    priority = 2; //нормальный приоритет
    if(!parent())setWindowIcon(QIcon(":/appimages/trayicon.png"));
    FileNameValidator *validator = new FileNameValidator(this);
    gui->fileName->setValidator(validator);
    gui->categoryBox->setValidator(validator);
    gui->saveFrame->setVisible(false);
    urlValidator();

    loadDatabaseData();
    connect(gui->categoryBox,SIGNAL(currentIndexChanged(int)),this,SLOT(updateLocation(int)));
    connect(gui->urlBox,SIGNAL(editTextChanged(QString)),this,SLOT(urlValidator()));
    connect(gui->browseButton,SIGNAL(released()),this,SLOT(openDirDialog()));
    connect(gui->startNowBtn,SIGNAL(released()),this,SLOT(startNow()));
    connect(gui->startLaterBtn,SIGNAL(released()),this,SLOT(startLater()));
    connect(gui->urlBox,SIGNAL(activated(QString)),this,SLOT(getCategory(QString)));
    connect(gui->saveButton,SIGNAL(released()),this,SLOT(updateTaskInfo()));
    connect(gui->cancelButton_2,SIGNAL(released()),this,SLOT(reject()));

    QDesktopWidget ds;
    QRect desktop = ds.availableGeometry();
    QPoint top_left = QPoint((desktop.bottomRight().x()-size().width())/2+20*(obj_cnt-1),(desktop.bottomRight().y()-size().height())/2+20*(obj_cnt-1));
    move(top_left);

    setAttribute(Qt::WA_AlwaysShowToolTips);
    gui->errorFrame->setHidden(true);

    scanClipboard();
}
Ejemplo n.º 17
0
void AddTaskDialog::urlValidator()
{
    if(gui->urlBox->currentText().isEmpty())
    {
        gui->startNowBtn->setEnabled(false);
        gui->startLaterBtn->setEnabled(false);
        gui->errorFrame->setHidden(true);
        return;
    }

    if(protocols.isEmpty())return;

    QUrl url(gui->urlBox->currentText());
    QString errorStr;

    if(!url.isValid())errorStr = tr("URL не корректен. Введите другой URL или исправьте этот.");
    else if(!protocols.contains(url.scheme().toLower()))errorStr = tr("Этот протокол не поддерживается. Проверьте наличие соответствующего плагина и его состояние.");

    if(errorStr.isEmpty())
    {
        gui->errorFrame->setHidden(true);
        gui->startNowBtn->setEnabled(true);
        gui->startLaterBtn->setEnabled(true);
    }
    else
    {
        gui->errorLabel->setText(errorStr);
        gui->errorFrame->setHidden(false);
        gui->startNowBtn->setEnabled(false);
        gui->startLaterBtn->setEnabled(false);
    }
    getCategory(gui->urlBox->currentText());
}
Aircraft::Aircraft(Type type, const TextureHolder& textures, const FontHolder& fonts)
: Entity(Table[type].hitpoints)
, mType(type)
, mFireCommand()
, mMissileCommand()
, mFireCountdown(sf::Time::Zero)
, mIsFiring(false)
, mIsLaunchingMissile(false)
, mShowExplosion(true)
, mSpawnedPickup(false)
, mSprite(textures.get(Table[type].texture), Table[type].textureRect)
, mExplosion(textures.get(Textures::Explosion))
, mFireRateLevel(1)
, mSpreadLevel(1)
, mMissileAmmo(2)
, mDropPickupCommand()
, mTravelledDistance(0.f)
, mDirectionIndex(0)
, mMissileDisplay(nullptr)
{
	mExplosion.setFrameSize(sf::Vector2i(256, 256));
	mExplosion.setNumFrames(16);
	mExplosion.setDuration(sf::seconds(1));

	centerOrigin(mSprite);
	centerOrigin(mExplosion);

	mFireCommand.category = Category::SceneAirLayer;
	mFireCommand.action   = [this, &textures] (SceneNode& node, sf::Time)
	{
		createBullets(node, textures);
	};

	mMissileCommand.category = Category::SceneAirLayer;
	mMissileCommand.action   = [this, &textures] (SceneNode& node, sf::Time)
	{
		createProjectile(node, Projectile::Missile, 0.f, 0.5f, textures);
	};

	mDropPickupCommand.category = Category::SceneAirLayer;
	mDropPickupCommand.action   = [this, &textures] (SceneNode& node, sf::Time)
	{
		createPickup(node, textures);
	};

	std::unique_ptr<TextNode> healthDisplay(new TextNode(fonts, ""));
	mHealthDisplay = healthDisplay.get();
	attachChild(std::move(healthDisplay));

	if (getCategory() == Category::PlayerAircraft)
	{
		std::unique_ptr<TextNode> missileDisplay(new TextNode(fonts, ""));
		missileDisplay->setPosition(0, 70);
		mMissileDisplay = missileDisplay.get();
		attachChild(std::move(missileDisplay));
	}

	updateTexts();
}
Ejemplo n.º 19
0
void SceneNode::onCommand(const Command& command, sf::Time dt)
{
  if(command.category & getCategory())
    command.action(*this, dt);

  FOREACH(Ptr& child, children)
    child->onCommand(command, dt);
}
Ejemplo n.º 20
0
void AddTaskDialog::setOtherFilename(const QString &flname)
{
    if(flname.isEmpty())
        return;

    gui->fileName->setText(flname);
    getCategory(gui->fileName->text());
}
int NaiveBayesianClassifier::getWordCount(const QString &category, const QString &word) 
{
    long idxsearch=-1;
    c4_Row findrow;
    c4_StringProp match("word");
    match(findrow)=word;

    c4_View cat = getCategory(category);
    idxsearch = getCategory(category).Find(findrow,idxsearch+1);
    if (idxsearch>=0) {
        c4_IntProp count("count");
        return count(cat[idxsearch]);
    } 
    else 
    {
        return 0;
    }
}
Ejemplo n.º 22
0
    void NTEventLogAppender::_append(const LoggingEvent& event) {
        const char* ps[1];
        ps[0] = event.message.c_str();

        const DWORD messageID = 0x1000;
        ::ReportEvent(_hEventSource, getType(event.priority), 
                  getCategory(event.priority), 
                  messageID, NULL, 1, 0, ps, NULL);
    }
Ejemplo n.º 23
0
void SceneNode::onCommand(const Command& command, sf::Time dt)
{
	// Command current node, if category matches
	if (command.category & getCategory())
		command.action(*this, dt);

	// Command children
	FOREACH(Ptr& child, mChildren)
		child->onCommand(command, dt);
}
Ejemplo n.º 24
0
void SceneNode::onCommand(const Command& command, sf::Time dt)
{
    if (command.category & getCategory())
    {
        command.action(*this, dt);
    }

    for(Ptr& child : mChildren)
    {
        child->onCommand(command, dt);
    }
}
Ejemplo n.º 25
0
CategoryWidget::CategoryWidget(WContainerWidget *parent)
               :WContainerWidget(parent)
{
   categoryContainer = new WContainerWidget(this);
   getCategory();
   
   new WText("Add new", this);
   categoryEdit = new WLineEdit(this);

   saveCategory = new WPushButton("Add", this);
   saveCategory->clicked().connect(this, &CategoryWidget::checkCategory);
}
Ejemplo n.º 26
0
void SceneNode::onCommand(const Command & command, sf::Time delta)
{
	if (command.category & getCategory())
	{
		command.action(*this, delta);
	}

	for (auto & child : children_)
	{
		child->onCommand(command, delta);
	}
}
Ejemplo n.º 27
0
char isObjectUsedInCategories( int inObjectID ) {
    CategoryRecord *r = getCategory( inObjectID );
    
    if( r != NULL && r->objectIDSet.size() > 0 ) {
        return true;
        }
    
    int num = getNumCategoriesForObject( inObjectID );
    

    return ( num > 0 );
    }
Ejemplo n.º 28
0
void MaterialCategoryModel::changeEvent(QEvent *event)
{
    if (event->type() == QEvent::LanguageChange) {

        MaterialCategory* cat;

        cat = getCategory("No Category");
        if (cat) cat->setDisplayName(tr("No Category"));

        cat = getCategory("Structural");
        if (cat) cat->setDisplayName(tr("Structural"));

        cat = getCategory("Structural Core");
        if (cat) cat->setDisplayName(tr("Structural Core"));

        cat = getCategory("Thermal Management");
        if (cat) cat->setDisplayName(tr("Thermal Management"));

        cat = getCategory("Glue");
        if (cat) cat->setDisplayName(tr("Glue"));

        cat = getCategory("Elementary");
        if (cat) cat->setDisplayName(tr("Elementary"));

    }
}
Ejemplo n.º 29
0
static void addCategory( int inParentID ) {
    
    if( getCategory( inParentID ) != NULL ) {
        // already exists
        return;
        }
    

    // add it to file structure
    File categoriesDir( NULL, "categories" );
            
    if( !categoriesDir.exists() ) {
        categoriesDir.makeDirectory();
        }
    
    if( ! categoriesDir.exists() || ! categoriesDir.isDirectory() ) {        

        printf( "Failed to make categories directory\n" );
        
        return;
        }
    
    
    // now add it to live, in memory database
    if( inParentID >= mapSize ) {
        // expand map

        int newMapSize = inParentID + 1;
        
        CategoryRecord **newMap = new CategoryRecord*[newMapSize];
        
        for( int i=0; i<newMapSize; i++ ) {
            newMap[i] = NULL;
            }

        memcpy( newMap, idMap, sizeof(CategoryRecord*) * mapSize );

        delete [] idMap;
        idMap = newMap;
        mapSize = newMapSize;
        }

    CategoryRecord *r = new CategoryRecord;
    
    r->parentID = inParentID;
    r->isPattern = false;
    r->isProbabilitySet = false;
    
    idMap[ inParentID ] = r;
    
    // don't save to disk now, because it's empty
    }
Ejemplo n.º 30
0
void SceneNode::onCommand(const Command &command, sf::Time dt)
{
    if (command.category & getCategory())
    {
        command.action(*this, dt);
        if (command.category == Category::Scene)
            return;
    }
    

    for (auto & child : mChildren)
        child->onCommand(command, dt);
}