当前位置: 首页>>代码示例>>C++>>正文


C++ Subsystem类代码示例

本文整理汇总了C++中Subsystem的典型用法代码示例。如果您正苦于以下问题:C++ Subsystem类的具体用法?C++ Subsystem怎么用?C++ Subsystem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Subsystem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: count_subsystem_particle_counts_for_match

bool count_subsystem_particle_counts_for_match (const Wavefunction<amplitude_t>::Amplitude &wf1, const Wavefunction<amplitude_t>::Amplitude &wf2,
                                                const Subsystem &subsystem)
{
    assert(subsystem.lattice_makes_sense(wf1.get_lattice()));
    assert(subsystem.lattice_makes_sense(wf2.get_lattice()));
    // (we are also assuming that the lattices are in fact equivalent)

    const PositionArguments &r1 = wf1.get_positions();
    const PositionArguments &r2 = wf2.get_positions();

    assert(r1.get_N_species() == r2.get_N_species());
    assert(r1.get_N_sites() == r2.get_N_sites());

    for (unsigned int species = 0; species < r1.get_N_species(); ++species) {
        assert(r1.get_N_filled(species) == r2.get_N_filled(species));

        unsigned int count1 = 0, count2 = 0;

        for (unsigned int i = 0; i < r1.get_N_filled(species); ++i) {
            const Particle particle(i, species);
            if (subsystem.position_is_within(r1[particle], wf1.get_lattice()))
                ++count1;
            if (subsystem.position_is_within(r2[particle], wf2.get_lattice()))
                ++count2;
        }

        if (count1 != count2)
            return false;
    }

    return true;
}
开发者ID:garrison,项目名称:vmc,代码行数:32,代码来源:SwappedSystem.cpp

示例2: update

void Engine::update()
{
	for( size_t i = 0; i < subsystems.size(); i++ )
	{
		Subsystem* system = subsystems[i];
		system->update();
	}

	resourceManager->update();

#ifdef ENABLE_SCRIPTING_LUA
	scriptManager->update();
#endif
}
开发者ID:,项目名称:,代码行数:14,代码来源:

示例3: sync

/**
 * Runs a single iteration of the loop.
 *
 * This method should be called often in order to have a functioning
 * {@link Command} system.  The loop has five stages:
 *
 * <ol>
 * <li> Poll the Buttons </li>
 * <li> Execute/Remove the Commands </li>
 * <li> Send values to SmartDashboard </li>
 * <li> Add Commands </li>
 * <li> Add Defaults </li>
 * </ol>
 */
void Scheduler::Run() {
  // Get button input (going backwards preserves button priority)
  {
    if (!m_enabled) return;

    std::lock_guard<priority_mutex> sync(m_buttonsLock);
    auto rButtonIter = m_buttons.rbegin();
    for (; rButtonIter != m_buttons.rend(); rButtonIter++) {
      (*rButtonIter)->Execute();
    }
  }

  m_runningCommandsChanged = false;

  // Loop through the commands
  auto commandIter = m_commands.begin();
  for (; commandIter != m_commands.end();) {
    Command* command = *commandIter;
    // Increment before potentially removing to keep the iterator valid
    commandIter++;
    if (!command->Run()) {
      Remove(command);
      m_runningCommandsChanged = true;
    }
  }

  // Add the new things
  {
    std::lock_guard<priority_mutex> sync(m_additionsLock);
    auto additionsIter = m_additions.begin();
    for (; additionsIter != m_additions.end(); additionsIter++) {
      ProcessCommandAddition(*additionsIter);
    }
    m_additions.clear();
  }

  // Add in the defaults
  auto subsystemIter = m_subsystems.begin();
  for (; subsystemIter != m_subsystems.end(); subsystemIter++) {
    Subsystem* lock = *subsystemIter;
    if (lock->GetCurrentCommand() == nullptr) {
      ProcessCommandAddition(lock->GetDefaultCommand());
    }
    lock->ConfirmCommand();
  }

  UpdateTable();
}
开发者ID:frc1678,项目名称:third-party,代码行数:62,代码来源:Scheduler.cpp

示例4: Init

void IdleAnimationTask::Init(idAI* owner, Subsystem& subsystem)
{
	// Just init the base class
	Task::Init(owner, subsystem);

	//Memory& memory = owner->GetMemory();

	// Read the animation set and interval from the owner's spawnarg
	_idleAnimationInterval = SEC2MS(owner->spawnArgs.GetInt("idle_animations_interval", "-1"));

	// Read the general-purpose animations first
	ParseAnimsToList(owner->spawnArgs.GetString("idle_animations"), _idleAnimations);
	
	// Now read the anims for the torso only
	ParseAnimsToList(owner->spawnArgs.GetString("idle_animations_torso"), _idleAnimationsTorso);

	// Now read the anims for sitting AI
	ParseAnimsToList(owner->spawnArgs.GetString("idle_animations_sitting"), _idleAnimationsSitting);

	if (_idleAnimationInterval > 0 && 
		(_idleAnimations.Num() > 0 || _idleAnimationsTorso.Num() > 0 || _idleAnimationsSitting.Num() > 0))
	{
		_nextAnimationTime = static_cast<int>(gameLocal.time + gameLocal.random.RandomFloat()*_idleAnimationInterval);
	}
	else
	{
		// No idle animation interval set or no animations, finish this task
		subsystem.FinishTask();
	}
}
开发者ID:ProfessorKaos64,项目名称:tdm,代码行数:30,代码来源:IdleAnimationTask.cpp

示例5: log

      //-----------------------------------------------------------------------
      virtual void log(
                       const Subsystem &inSubsystem,
                       Log::Severity inSeverity,
                       Log::Level inLevel,
                       CSTR inMessage,
                       CSTR inFunction,
                       CSTR inFilePath,
                       ULONG inLineNumber
                       )
      {
        IClientLogDelegatePtr delegate;

        // scope: get the delegate
        {
          AutoRecursiveLock lock(mLock);
          delegate = mDelegate;
        }
        if (!delegate)
          return;

        delegate->onLog(
                        (PTRNUMBER)(&inSubsystem),
                        inSubsystem.getName(),
                        severityToSeverity(inSeverity),
                        levelToLevel(inLevel),
                        inMessage,
                        inFunction,
                        inFilePath,
                        inLineNumber
                        );
      }
开发者ID:Gurtej,项目名称:op,代码行数:32,代码来源:hookflash_Client.cpp

示例6: ClientException

Client::Client(Resources& resources, Subsystem& subsystem, hostaddr_t host,
    hostport_t port, Configuration& config, const std::string& password)
    throw (Exception)
    : ClientServer(host, port),
      Gui(resources, subsystem, resources.get_font("normal")),
      OptionsMenu(*this, resources, subsystem, config, this),
      resources(resources), subsystem(subsystem), player_config(config),
      logged_in(false), me(0), updatecnt(0),
      factory(resources, subsystem, this), my_id(0), login_sent(false),
      throw_exception(false), exception_msg(), force_send(false),
      fhnd(0), running(true), reload_resources(true)
{
    conn = 0;
    get_now(last);
    update_text_fade_speed();

    /* start data receiver thread */
    if (!thread_start()) {
        throw ClientException("Starting client thread failed.");
    }

    /* login */
    GPlayerDescription player_desc;
    memset(&player_desc, 0, sizeof(GPlayerDescription));
    strncpy(player_desc.player_name, player_config.get_player_name().c_str(), NameLength - 1);
    strncpy(player_desc.characterset_name, player_config.get_player_skin().c_str(), NameLength - 1);
    {
        Scope<Mutex> lock(mtx);
        login(password, GPlayerDescriptionLen, &player_desc);
    }
    binding.extract_from_config(player_config);

    /* start music player */
    subsystem.start_music_player(resources, *this, config.get_string("external_music").c_str());
}
开发者ID:goatattack,项目名称:goatattack,代码行数:35,代码来源:Client.cpp

示例7: wpi_setWPIErrorWithContext

/**
 * Removes the {@link Command} from the {@link Scheduler}.
 *
 * @param command the command to remove
 */
void Scheduler::Remove(Command* command) {
  if (command == nullptr) {
    wpi_setWPIErrorWithContext(NullParameter, "command");
    return;
  }

  if (!m_commands.erase(command)) return;

  Command::SubsystemSet requirements = command->GetRequirements();
  auto iter = requirements.begin();
  for (; iter != requirements.end(); iter++) {
    Subsystem* lock = *iter;
    lock->SetCurrentCommand(nullptr);
  }

  command->Removed();
}
开发者ID:frc1678,项目名称:third-party,代码行数:22,代码来源:Scheduler.cpp

示例8: Init

void GreetingBarkTask::Init(idAI* owner, Subsystem& subsystem)
{
	// Init the base class
	SingleBarkTask::Init(owner, subsystem);

	// Check the prerequisites - are both AI available for greeting?
	if ( !owner->CanGreet() || !_greetingTarget->CanGreet() || owner->m_isMute ) // grayman #3338
	{
		// Owner or other AI cannot do greetings
		subsystem.FinishTask();
		return;
	}

	// Allow state "waiting for greeting" for owner
	// Allow state "after Greeting" for the other AI
	if ( ( ( owner->greetingState != ENotGreetingAnybody )           && ( owner->greetingState != EWaitingForGreeting ) ) || 
		 ( ( _greetingTarget->greetingState != ENotGreetingAnybody ) && ( _greetingTarget->greetingState != EAfterGreeting ) ) )
	{
		// Someone is busy
		DM_LOG(LC_AI, LT_INFO)LOGSTRING("Cannot greet: one of the actors is busy: %s to %s\r", owner->name.c_str(), _greetingTarget->name.c_str());
		subsystem.FinishTask();
		return;
	}

	// grayman #3415 - If both actors are sitting, disallow a greeting, on the
	// assumption that they've been that way for awhile, and any greetings would
	// already have happened. To keep pent-up greetings from occurring when one
	// actor stands up, move the allowed greeting time into the future.

	idAI* otherAI = static_cast<idAI*>(_greetingTarget);
	if ( (owner->GetMoveType() == MOVETYPE_SIT ) && (otherAI->GetMoveType() == MOVETYPE_SIT ) )
	{
		int delay = (MINIMUM_TIME_BETWEEN_GREETING_SAME_ACTOR + gameLocal.random.RandomInt(EXTRA_DELAY_BETWEEN_GREETING_SAME_ACTOR))*1000;
		int nextGreetingTime = gameLocal.time + delay;
		owner->GetMemory().GetGreetingInfo(otherAI).nextGreetingTime = nextGreetingTime;
		otherAI->GetMemory().GetGreetingInfo(owner).nextGreetingTime = nextGreetingTime;
		subsystem.FinishTask();
		return;
	}

	// Both AI are not greeting each other so far, continue
	owner->greetingState = EGoingToGreet;
	_greetingTarget->greetingState = EWaitingForGreeting;
}
开发者ID:dolanor,项目名称:TheDarkMod,代码行数:44,代码来源:GreetingBarkTask.cpp

示例9: count_subsystem_sites

unsigned int BaseSwapPossibleWalk::count_subsystem_sites (const Subsystem &subsystem, const Lattice &lattice)
{
    // (this is a static method)
    unsigned int N_subsystem_sites = 0;
    for (unsigned int i = 0; i < lattice.total_sites(); ++i) {
        if (subsystem.position_is_within(i, lattice))
            ++N_subsystem_sites;
    }
    return N_subsystem_sites;
}
开发者ID:mishmash,项目名称:vmc,代码行数:10,代码来源:BaseSwapPossibleWalk.cpp

示例10: Init

void ResolveMovementBlockTask::Init(idAI* owner, Subsystem& subsystem)
{
	// Just init the base class
	Task::Init(owner, subsystem);

	owner->GetMemory().resolvingMovementBlock = true;

	if (_blockingEnt == NULL)
	{
		DM_LOG(LC_AI, LT_WARNING)LOGSTRING("AI %s cannot resolve a NULL blocking entity.\r", owner->name.c_str());
		owner->PushMove(); // grayman #2706 - save movement state, because it gets popped in OnFinish()
		subsystem.FinishTask();
	}

	// Get the direction we're pushing against
	_initialAngles = owner->viewAxis.ToAngles();

	// Set the TTL for this task
	_endTime = gameLocal.time + 20000; // 20 seconds

	// Save the movement state
	owner->PushMove();

	if (_blockingEnt->IsType(idAI::Type))
	{
		//DM_LOG(LC_AI, LT_WARNING)LOGSTRING("AI %s starting to resolve blocking AI: %s\r", owner->name.c_str(), _blockingEnt->name.c_str());
		InitBlockingAI(owner, subsystem);
	}
	else if (_blockingEnt->IsType(idStaticEntity::Type))
	{
		//DM_LOG(LC_AI, LT_WARNING)LOGSTRING("AI %s starting to resolve static blocking entity: %s\r", owner->name.c_str(), _blockingEnt->name.c_str());
		InitBlockingStatic(owner, subsystem);
	}
	else
	{
		// Unknown entity type, exit task
		//DM_LOG(LC_AI, LT_WARNING)LOGSTRING("AI %s cannot resolve blocking entity: %s\r", owner->name.c_str(), _blockingEnt->name.c_str());
		subsystem.FinishTask(); 
	}
}
开发者ID:dolanor,项目名称:TheDarkMod,代码行数:40,代码来源:ResolveMovementBlockTask.cpp

示例11: png

Font::Font(Subsystem& subsystem, const std::string& filename, ZipReader *zip)
    throw (KeyValueException, FontException)
    : Properties(filename + ".font", zip), subsystem(subsystem)
{
    try {
        PNG png(filename + ".png", zip);
        /* setup font operations */
        FontOperations fo;
        if (zip) {
            fo.handle = zip;
            fo.open = &fo_zip_open;
            fo.read = &fo_zip_read;
            fo.close = &fo_zip_close;
        } else {
            fo.handle = 0;
            fo.open = &fo_file_open;
            fo.read = &fo_file_read;
            fo.close = &fo_file_close;
        }

        std::string font_description = filename + ".fds";
        fo.open(fo, font_description);

        char header[4];
        fo.read(fo, header, sizeof(header));
        if (memcmp(header, "FNT1", 4)) {
            throw FontException("wrong font file " + font_description);
        }
        fo.read(fo, &font_height, sizeof font_height);
        font_height = ntohl(font_height) * 2;
        spacing = atoi(get_value("spacing").c_str());

        font_char_t font;
        for (int i = 0; i < NumOfChars; i++) {
            fo.read(fo, &font, sizeof font);
            font.origin_x = ntohl(font.origin_x);
            font.origin_y = ntohl(font.origin_y);
            font.width = ntohl(font.width);
            font.height = ntohl(font.height);

            TileGraphic *tg = subsystem.create_tilegraphic(font.width, font.height);
            tg->punch_out_tile(png, font.origin_x, font.origin_y, false);
            tiles[i] = new Tile(tg, false, Tile::TileTypeNonblocking, 0, false, 0.0f);
            fw[i] = font.width;
            fh[i] = font.height;
        }
    } catch (const Exception& e) {
        throw FontException(e.what());
    }

}
开发者ID:SuperNascher,项目名称:goatattack,代码行数:51,代码来源:Font.cpp

示例12: Init

void PlayAnimationTask::Init(idAI* owner, Subsystem& subsystem)
{
	// Just init the base class
	Task::Init(owner, subsystem);

	// Parse animation spawnargs here
	if (_animName.IsEmpty())
	{
		gameLocal.Warning("%s cannot start PlayAnimationTask with empty animation name.",owner->name.c_str());
		subsystem.FinishTask();
	}

	StartAnim(owner);
}
开发者ID:dolanor,项目名称:TheDarkMod,代码行数:14,代码来源:PlayAnimationTask.cpp

示例13: onNewSubsystem

      //-----------------------------------------------------------------------
      virtual void onNewSubsystem(Subsystem &inSubsystem)
      {
        IClientLogDelegatePtr delegate;

        // scope: get the delegate
        {
          AutoRecursiveLock lock(mLock);
          mSubsystems[(PTRNUMBER)(&inSubsystem)] = &inSubsystem;
          delegate = mDelegate;
        }

        if (!delegate)
          return;

        delegate->onNewSubsystem((PTRNUMBER)(&inSubsystem), inSubsystem.getName());
      }
开发者ID:Gurtej,项目名称:op,代码行数:17,代码来源:hookflash_Client.cpp

示例14: Init

void InvestigateSpotTask::Init( idAI *owner, Subsystem &subsystem ) {
	// Just init the base class
	Task::Init( owner, subsystem );
	// Get a shortcut reference
	Memory &memory = owner->GetMemory();
	// Stop previous moves
	//owner->StopMove(MOVE_STATUS_DONE);
	if( memory.currentSearchSpot != idVec3( idMath::INFINITY, idMath::INFINITY, idMath::INFINITY ) ) {
		// Set the goal position
		SetNewGoal( memory.currentSearchSpot );
	} else {
		// Invalid hiding spot, terminate task
		DM_LOG( LC_AI, LT_DEBUG )LOGSTRING( "memory.currentSearchSpot not set to something valid, terminating task.\r" );
		subsystem.FinishTask();
	}
	//_exitTime = 0; // grayman #3507
}
开发者ID:,项目名称:,代码行数:17,代码来源:

示例15: MusicException

Music::Music(Subsystem& subsystem, const std::string& filename, ZipReader *zip)
    throw (KeyValueException, MusicException)
    : Properties(filename + ".music", zip), subsystem(subsystem), audio(0),
      do_not_play_in_music_player(false), audio_filename(filename)
{
    try {
        audio = subsystem.create_audio();
        audio->generate_music(filename + ".ogg", zip);
    } catch (const AudioException& e) {
        if (audio) {
            delete audio;
            throw MusicException(e.what());
        }
    }

    do_not_play_in_music_player = (atoi(get_value("do_not_play_in_music_player").c_str()) ? true : false);
}
开发者ID:goatattack,项目名称:goatattack,代码行数:17,代码来源:Music.cpp


注:本文中的Subsystem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。