コード例 #1
0
ファイル: ObjectSet.cpp プロジェクト: akva2/BSGUI
QString Component::displayString()
{
    Components *p = static_cast<Components *>(_parent);
    return (QString("%1 %2")
            .arg(p->cType() == CT_FACE ? "Face" : (p->cType() == CT_EDGE ? "Edge" : "Vertex"))
            .arg(_index + 1));
}
コード例 #2
0
ファイル: GameController.cpp プロジェクト: treycucco/BNTCops
GameController::GameController()
{
  // TODO: All this static initialization will have to be done through some other
  //       means. This is just for testing purposes.
  Box areaSize(100, 100);
  
  _player = new Character("Trey Cucco", Traits(5, 7, 6, 7, 8, 7, 5), Character::Gender::Male);
  _player->currentPosition(areaSize.center());
  _area = new Area(areaSize, "The Arena!", "The arena is where we test out moving, fighting and NPC AI. We hope to use this as the primary test bed for much of the game engine.");

  _area->npcs().push_back(new Character("Johnny Ringo", Traits(2, 2, 2, 2, 2, 6, 2), Character::Gender::Male));
  _area->npcs().push_back(new Character("Ike Clanton", Traits(3, 3, 3, 3, 3, 6, 3), Character::Gender::Male));
  _area->npcs()[0]->currentPosition(areaSize.center() + Point(areaSize.width() / 10, areaSize.height() / 8));
  _area->npcs()[1]->currentPosition(areaSize.center() + Point(-areaSize.width() / 7, -areaSize.height() / 15));

  double radius = areaSize.width() / 2;
  for (int c = 0; c < areaSize.width(); ++c)
  {
    for (int r = 0; r < areaSize.height(); ++r)
    {
      Point p(c, r);
      if (Components::dist(p, areaSize.center()) > radius)
      {
        _area->location(p).locationType(Models::AreaLocationType::Barrier);
      }
    }
  }
  
  for (auto i = _area->npcs().begin(); i != _area->npcs().end(); ++i)
  {
    _area->location((*i)->currentPosition()).occupyingCharacter(*i);
  }
  _area->location(_player->currentPosition()).occupyingCharacter(_player);
}
int main() {
    Components test;
    vector<pair<int, int>> edges1 = {{0, 1}, {1, 2}, {3, 4}};
    vector<pair<int, int>> edges2 = {{0, 1}, {1, 2}, {2, 3}, {3, 4}};
    cout << test.countComponents(5, edges1) << " " << test.countComponents(5, edges2) << endl;

}
コード例 #4
0
ファイル: CompositeOTText.cpp プロジェクト: kennytm/tticomp
GlyphId CompositeText::addToFont(String name) {
    Exception::FontContext c1 (font);

    HorMetric hm;
    hm.advanceWidth = 0;
    hm.lsb = 0;
    Components components;
    Chars::iterator c;
    UShort totalAdvance = 0;
    for (c = chars.begin(); c != chars.end(); c ++) {
        totalAdvance += (*c)->getAdvance();
    }
    for (c = chars.begin(); c != chars.end(); c ++) {
        ((CompositeChar &)(**c)).addToComponents (components, hm, totalAdvance);
    }
    GlyphPtr newGlyph;
    if (components.empty())
        newGlyph = new Glyph (font, name, hm);
    else {
        newGlyph = new CompositeGlyph (font, name, hm, components);
        hm.lsb = newGlyph->getDisplacement();
        newGlyph->setHorMetric (hm);
    }
    return font.addGlyph (newGlyph);
}
コード例 #5
0
ファイル: Timestamp.cpp プロジェクト: caitp/TimedText
Timestamp
Timestamp::fromComponents(const Timestamp::Components &c)
{
  Components normal = c;
  normal.normalize();
  return Timestamp((c.hours * millisPerHour)
                 + (c.minutes * millisPerMinute)
                 + (c.seconds * millisPerSecond)
                 + (c.msec));
}
コード例 #6
0
void PhysicsComponent::registerComponent(Components& components)
{
	Component::registerComponent(components);

	components.subscribeMessageType(*this, ComponentInterface::ePositionChangedMsg);
   components.subscribeMessageType(*this, ComponentInterface::eRotationChangedMsg);
   components.subscribeMessageType(*this, ComponentInterface::eQueryBodyMsg);

   mpBody->setEntity(getEntity());
}
コード例 #7
0
ファイル: Timestamp.cpp プロジェクト: caitp/TimedText
void
Timestamp::setComponents(const Timestamp::Components &c)
{
  Components normal = c;
  normal.normalize();
  ms = (c.hours * millisPerHour)
     + (c.minutes * millisPerMinute)
     + (c.seconds * millisPerSecond)
     + (c.msec);
}
コード例 #8
0
void ComponentsUnitTests::testLcidFilters()
{
    Components components;
    ComponentPtr component_currentlcid(new MsiComponent());
    component_currentlcid->os_filter_lcid = L"1040";
    ComponentPtr component_anotherlcid(new MsiComponent());
    component_anotherlcid->os_filter_lcid = L"!1040";
    components.add(component_currentlcid);
    components.add(component_anotherlcid);
    Assert::IsTrue(components.size() == 2);
    Assert::IsTrue(components.GetSupportedComponents(LcidUser, SequenceInstall).size() == 1);
}
コード例 #9
0
void ComponentsUnitTests::testExecNoCallback()
{
    Components components;
    CmdComponent * component1 = new CmdComponent();
    component1->id = DVLib::GenerateGUIDStringW();
    std::wstring check_file = DVLib::DirectoryCombine(DVLib::GetTemporaryDirectoryW(), component1->id);
    Assert::IsTrue(! DVLib::FileExists(check_file));
    component1->command = L"cmd.exe /C dir > \"" + check_file + L"\"";
    components.add(ComponentPtr(component1));
    components.Exec(NULL);
    Assert::IsTrue(DVLib::FileExists(check_file));
    DVLib::FileDelete(check_file);
}
コード例 #10
0
void ComponentsUnitTests::testPAFilters()
{
    Components components;
    ComponentPtr component_currentpa(new MsiComponent());
    component_currentpa->processor_architecture_filter = L"mips";
    ComponentPtr component_anotherpa(new MsiComponent());
    component_anotherpa->processor_architecture_filter = L"x86,x64";
    components.add(component_currentpa);
    components.add(component_anotherpa);
    Assert::IsTrue(components.size() == 2);
    Assert::IsTrue(components.GetSupportedComponents(LcidUser, SequenceInstall).size() == 1);
    Assert::IsTrue(get(components.GetSupportedComponents(LcidUser, SequenceInstall)[0]) == get(component_anotherpa));
}
コード例 #11
0
ファイル: f8precomp.cpp プロジェクト: mattyv/fix8
//-----------------------------------------------------------------------------------------
void process_component(const XmlElement& xf, const Components& components, const int depth, ostream& outf)
{
	string name;
	xf.GetAttr("name", name);
	Components::const_iterator citr(components.find(name));
	if (citr == components.end())
	{
		cerr << shortName << ':' << recover_line(xf) << ": error: Could not find component " << name << endl;
		++glob_errors;
	}
	else
		for(XmlElement::XmlSet::const_iterator itr(citr->second->begin()); itr != citr->second->end(); ++itr)
			process_elements(itr, components, depth, outf);
}
コード例 #12
0
void ComponentsUnitTests::testAdd()
{
    Components components;
    ComponentPtr component1(new CmdComponent());
    component1->id = DVLib::GenerateGUIDStringW();
    ComponentPtr component2(new CmdComponent());
    component2->id = DVLib::GenerateGUIDStringW();
    components.add(component1);
    components.add(component2);
    Assert::IsTrue(components.size() == 2);
    Assert::IsTrue(components.contains(component1->id));
    Assert::IsTrue(components.contains(component2->id));
    Assert::IsTrue(! components.contains(DVLib::GenerateGUIDStringW()));
}
コード例 #13
0
void ComponentsUnitTests::testExecWithError()
{
    Components components;
    CmdComponent * component1 = new CmdComponent();
    component1->id = DVLib::GenerateGUIDStringW();
    component1->command = L"foobar.exe";
    components.add(ComponentPtr(component1));
    ExecuteComponentCallbackImpl callback;
    components.Exec(& callback);
    Assert::IsTrue(1 == callback.starts);
    Assert::IsTrue(1 == callback.begins);
    Assert::IsTrue(0 == callback.waits);
    Assert::IsTrue(0 == callback.successes);
    Assert::IsTrue(1 == callback.errors);
}
コード例 #14
0
poison::Components poison::DefaultEntityManager::getComponentsForEntity(Entity* entity) {
    ComponentsIndex::index<Component::byEntityIdTag>::type::iterator first, last;
    boost::tuples::tie(first, last) = componentsContainer_.get<Component::byEntityIdTag>().equal_range(entity->getId());
    Components components;
    
    if (first != componentsContainer_.get<Component::byEntityIdTag>().end()) {
        
        auto size = std::distance(first, last);
        components.reserve(size);
        for (auto it = first; it != last; ++it) {
            components.push_back( (*it).get() );
        }
    }
    
    return components;
}
コード例 #15
0
ファイル: CompositeOTText.cpp プロジェクト: kennytm/tticomp
void CompositeChar::addToComponents (Components &components, HorMetric &hm, UShort totalAdvance) {
    // Current "pen" position is hm.advanceWidth
    ComponentPtr c;
    GlyphPtr glyph = font.getGlyph (glyphId);
    if (!glyph->isEmpty()) {
        CompositeComponent::Flags flags;
        if (totalAdvance && totalAdvance == advance && position.x == 0) {
            flags = CompositeComponent::Flags (
                        CompositeComponent::cfRoundXYToGrid | CompositeComponent::cfUseMyMetrics);
        } else
            flags = CompositeComponent::cfRoundXYToGrid;

        CompositeComponent::Scale scale;// = {0x4000, 0, 0, 0x4000};
        scale.xx = scale.yy = 1;
        scale.xy = scale.yx = 0;
        if (thisAttachPoint == 0xFFFF) {
            CompositeComponent::Translation translation = {hm.advanceWidth -
                                                           glyph->getDisplacement() + position.x, position.y
                                                          };
            c = new PositionedCompositeComponent (font, glyphId, flags,
                                                  scale, translation);
        } else {
            c = new AttachedCompositeComponent (font, glyphId, flags,
                                                scale, baseAttachPoint, thisAttachPoint);
        }
        components.push_back (c);
    }
    hm.advanceWidth += advance;
}
コード例 #16
0
ファイル: f8precomp.cpp プロジェクト: Fantasticer/fix8
//-----------------------------------------------------------------------------------------
void dump_components(const Components& components, ostream& outf)
{
	if (components.empty())
		return;

	int depth(1);

	outf << string(depth * 2, ' ') << "<components>" << endl;

	for (Components::const_iterator citr(components.begin()); citr != components.end(); ++citr)
	{
		outf << string((depth + 1) * 2, ' ') << "<component name=\"";
		outf << citr->first << "\" id=\"" << (1 + distance(components.begin(), citr)) << "\"/>" << endl;
	}

	outf << string(depth * 2, ' ') << "</components>" << endl;
}
コード例 #17
0
void ComponentsUnitTests::testOsFilters()
{
    Components components;
    ComponentPtr component1(new MsiComponent());
    component1->os_filter = L"!winXP";
    ComponentPtr component2(new MsiComponent());
    component2->os_filter = L"winXPsp1";
    ComponentPtr component3(new MsiComponent());
    component3->os_filter = L"winXP";
    ComponentPtr component4(new MsiComponent());
    components.add(component1);
    components.add(component2);
    components.add(component3);
    components.add(component4);
    Assert::IsTrue(components.size() == 4);
    Assert::IsTrue(components.GetSupportedComponents(LcidUser, SequenceInstall).size() == 2);
}
コード例 #18
0
int InstallerWindow::ExecOnThread()
{
	try
	{
		auto_any<htmlayout::dom::element *, html_disabled> btn_install(& button_install);
		htmlayout::queue::push(new html_set_attribute_task(& button_install, "disabled", L"disabled"), HtmlWindow::s_hwnd);
		auto_any<htmlayout::dom::element *, html_disabled> btn_skip(& button_skip);
		htmlayout::queue::push(new html_set_attribute_task(& button_skip, "disabled", L"disabled"), HtmlWindow::s_hwnd);

		ClearError();
		ClearProgress();

		InstallConfiguration * p_configuration = reinterpret_cast<InstallConfiguration *>(get(m_configuration));
		CHECK_BOOL(p_configuration != NULL, L"Invalid configuration");

		if (RestartElevated())
		{
			OnCancel();
			return 0;
		}

		Components components = p_configuration->GetSupportedComponents(
			InstallerSession::Instance->lcidtype, InstallerSession::Instance->sequence);

		SetProgressTotal(components.size() * 2);

		int rc = components.Exec(this);
		InstallerUI::AfterInstall(rc);
		return 0;
    }
    catch(std::exception& ex)
    {
		LOG(L"*** Failed to install one or more components: " << DVLib::string2wstring(ex.what()));
		ShowError(DVLib::string2wstring(ex.what()));
		RecordError();
    }
	catch(...)
	{
		LOG(L"*** Failed to install one or more components");
		ShowError(TEXT("Failed to install one or more components"));
		RecordError();
	}

	return 0;
}
コード例 #19
0
void ComponentsUnitTests::testOsFiltersGreaterSmaller()
{
    Components components;
    ComponentPtr component1(new MsiComponent());
    component1->os_filter_min = winNone;
    component1->os_filter_max = winXPMax;
    ComponentPtr component2(new MsiComponent());
    component2->os_filter_min = winXP;
    component2->os_filter_max = winServer2003Max;
    ComponentPtr component3(new MsiComponent());
    component3->os_filter_min = winXP;
    component3->os_filter_max = winNone;
    components.add(component1);
    components.add(component2);
    components.add(component3);
    Assert::IsTrue(components.size() == 3);
    Assert::IsTrue(components.GetSupportedComponents(LcidUser, SequenceInstall).size() == 1);
}
コード例 #20
0
ファイル: components.hpp プロジェクト: Kuxe/swordbow-magic
 void sync(const Components<T>& components) {
     try {
         for(const auto& it : components) {
             container[it.first] = components.get(it.first);
         }
     } catch(const std::exception& e) {
         Logger::error("Could not sync components");
     }
 }
コード例 #21
0
ファイル: f8precomp.cpp プロジェクト: Fantasticer/fix8
//-----------------------------------------------------------------------------------------
void load_components(const XmlElement::XmlSet& comlist, Components& components)
{
	for(const auto *pp : comlist)
	{
		string name;
		if (pp->GetAttr("name", name))
			components.insert({name, pp});
	}
}
コード例 #22
0
ファイル: f8precomp.cpp プロジェクト: jzsu/fix8
//-----------------------------------------------------------------------------------------
void load_components(const XmlElement::XmlSet& comlist, Components& components)
{
	for(XmlElement::XmlSet::const_iterator itr(comlist.begin()); itr != comlist.end(); ++itr)
	{
		string name;
		if ((*itr)->GetAttr("name", name))
			components.insert(Components::value_type(name, *itr));
	}
}
コード例 #23
0
ファイル: f8precomp.cpp プロジェクト: Fantasticer/fix8
//-----------------------------------------------------------------------------------------
void process_component(const XmlElement& xf, const Components& components, const int depth, ostream& outf, bool required)
{
	string name;
	xf.GetAttr("name", name);
	bool comp_required(xf.FindAttr("required", false));

	Components::const_iterator citr(components.find(name));
	if (citr == components.end())
	{
		cerr << shortName << ':' << recover_line(xf) << ": error: Could not find component '" << name << '\'' << endl;
		++glob_errors;
	}
	else
	{
		for(XmlElement::XmlSet::const_iterator itr(citr->second->begin()); itr != citr->second->end(); ++itr)
			process_elements(itr, components, depth, outf, name,
				depth == 3 ? comp_required : comp_required && required);
	}
}
コード例 #24
0
void ComponentsUnitTests::testExecWithCallback()
{
    Components components;
    CmdComponent * component1 = new CmdComponent();
    component1->id = DVLib::GenerateGUIDStringW();
    std::wstring check_file = DVLib::DirectoryCombine(DVLib::GetTemporaryDirectoryW(), component1->id);
    Assert::IsTrue(! DVLib::FileExists(check_file));
    component1->command = L"cmd.exe /C dir > \"" + check_file + L"\"";
    components.add(ComponentPtr(component1));
    ExecuteComponentCallbackImpl callback;
    components.Exec(& callback);
    Assert::IsTrue(DVLib::FileExists(check_file));
    DVLib::FileDelete(check_file);
    Assert::IsTrue(1 == callback.starts);
    Assert::IsTrue(1 == callback.begins);
    Assert::IsTrue(1 == callback.waits);
    Assert::IsTrue(1 == callback.successes);
    Assert::IsTrue(0 == callback.errors);
}
コード例 #25
0
int XMLManager::SaveXML(string fileName, Components components, Groups groups){
    //創建檔案
    xmlFile.open(fileName.c_str(),ios::out);
    if(xmlFile.is_open()){
        AddComponentAndGroupToXMLFile(components.GetAllComponent(),groups.GetAllGroups());
        this->xmlFilePath = fileName; //把路徑記錄下來
         xmlFile.close();
        return XMLErrorCode::OK;
    }
    else{ //創建後如果無開啟 代表可能有錯誤
        xmlFile.close();
        return XMLErrorCode::Save_PathError;
    }
}
コード例 #26
0
ファイル: TagWriter.cpp プロジェクト: c2lang/c2compiler
TagWriter::TagWriter(const c2lang::SourceManager& SM_, const Components& components)
    : SM(SM_)
    , currentFile(0)
{
    for (unsigned c=0; c<components.size(); c++) {
        const ModuleList& mods = components[c]->getModules();
        for (unsigned m=0; m<mods.size(); m++) {
            const AstList& modFiles = mods[m]->getFiles();
            for (unsigned i=0; i<modFiles.size(); i++) {
                analyse(*modFiles[i]);
            }
        }
    }
}
コード例 #27
0
ファイル: problem70.cpp プロジェクト: stdk/euler
auto search(uint32_t limit, const PrimeNumbers &primes) {
    const size_t iteration_limit = 10000;

    auto initial = initial_candidate(limit, primes);
    Components components = {initial, initial};

    for(size_t i=0;components.size() && i<iteration_limit;++i,components=next(components,initial,limit,primes)) {
        auto fraction = quotient(components);

        if(is_permuted_pair(fraction.p(),fraction.q())) {
            if(!util::test_mode()) {
                fmt::print("[{}] {}x{} -> {} ({})\n",i,
                                                *components[0],
                                                *components[1],
                                                 fraction,
                                                 static_cast<double>(fraction));
            }
            return std::make_tuple(true,fraction);
        };
    }

    return std::make_tuple(false,quotient(Components{}));
}
コード例 #28
0
Components *Entity::Clone()
{
	Components *entity = new Entity();
	entity->SetId(this->GetId());
	entity->SetType(this->GetType());
	entity->SetName(this->GetName());
	entity->SetPointX(this->GetPointX());
	entity->SetPointY(this->GetPointY());
	return entity;
}
コード例 #29
0
Components *Attributes::Clone()
{
    Components *attributes = new Attributes();
    attributes->SetId(this->GetId());
    attributes->SetType(this->GetType());
    attributes->SetName(this->GetName());
    attributes->SetPointX(this->GetPointX());
    attributes->SetPointY(this->GetPointY());
    return attributes;
}
コード例 #30
0
void ComponentsUnitTests::testLoadUninstallSequence()
{
    Components components;
    CmdComponent * component1 = new CmdComponent();
    component1->id = DVLib::GenerateGUIDStringW();
    components.add(ComponentPtr(component1));
    CmdComponent * component2 = new CmdComponent();
    component2->id = DVLib::GenerateGUIDStringW();
    components.add(ComponentPtr(component2));
    Assert::IsTrue(components.GetSupportedComponents(LcidUser, SequenceInstall).size() == 2);
    Assert::IsTrue(components.GetSupportedComponents(LcidUser, SequenceInstall)[0]->id == component1->id);
    Assert::IsTrue(components.GetSupportedComponents(LcidUser, SequenceInstall)[1]->id == component2->id);
    Assert::IsTrue(components.GetSupportedComponents(LcidUser, SequenceUninstall).size() == 2);
    Assert::IsTrue(components.GetSupportedComponents(LcidUser, SequenceUninstall)[0]->id == component2->id);
    Assert::IsTrue(components.GetSupportedComponents(LcidUser, SequenceUninstall)[1]->id == component1->id);
}