Example #1
0
int main(int argc, char* argv[])
{
    if (argc < 3) {
        print_error(ERROR_FEW_ARGS);
        return ERROR_FEW_ARGS;
    }
    std::string rootpath = argv[1];
    std::string dirpath = argv[2];

    std::vector<std::string> vpath;
    size_t pathResult = get_path(dirpath, vpath);
    if ((pathResult != SUCCESS) || (vpath.size() < 1)) {
        print_error(pathResult);
        return pathResult;
    }

    Root* root = new Root(rootpath);
    Bitmap* bitmap = new Bitmap(root);

    if (root->get_freeBlocksCount() < 1) {
        print_error(ERROR_NOT_ENOUGH_SPACE);
        return ERROR_NOT_ENOUGH_SPACE;
    }
    Dir* rootDir = root->get_rootDir();
    rootDir->readSelf(root);

    size_t result = create_dirpath(bitmap, rootDir, vpath.begin(), vpath.end());
    if (result != SUCCESS) {
        print_error(result);
        return result;
    }
    SaveFS(root, bitmap, rootDir);

    return SUCCESS;
}
Example #2
0
	int startup()
	{
		_root = new Root("plugins_d.cfg");
		
		if (!_root->showConfigDialog()) {
			return -1;
		}

		RenderWindow* window = _root->initialise(true, "Lab 4");
		_sceneManager = _root->createSceneManager(ST_GENERIC);

		Camera* camera = _sceneManager->createCamera("Camera");
		camera->setPosition(Ogre::Vector3(0,0,50));
		camera->lookAt(Ogre::Vector3(0,0,0));
		camera->setNearClipDistance(5);

		Viewport *viewPort = window->addViewport(camera);
		viewPort->setBackgroundColour(ColourValue(0.0,0.0,0.0));

		camera->setAspectRatio(Real(viewPort->getActualWidth())/Real(viewPort->getActualHeight()));

		loadResources(); 
		createScene();

		_listener = new MyFrameListener(window, camera, new CylindricalEffect(_myCube, Ogre::Vector3(2.0, 10.0, 0.0), Ogre::Vector3(0.0, 0.0, 0.1)));
		_root->addFrameListener(_listener);
		return 0;
	}
Example #3
0
template <class R, class N, class K, int n> inline void TreeInNode<R, N, K, n>::check() const {
	N const* me = static_cast<N const*>(this);
	if (root_) {
		Root* myroot = root_;
		if (parent_ == 0) {
			assert(static_cast<Root*>(root_)->base_ == me);
		} else {
			Node* myparent = static_cast<Node*>(parent_);
			assert(myparent->left_ == me || myparent->right_ == me);
			assert(myparent->root_ == root_);
		}

		if (left_) {
			Node* myleft = static_cast<Node*>(left_);
			assert(myleft->parent_ == me);
			assert(myroot->compare(*me, *left_) <= 0);
			assert(myroot->compare(*left_, *me) >= 0);
		}

		if (right_) {
			Node* myright = static_cast<Node*>(right_);
			assert(myright->parent_ == me);
			assert(myroot->compare(*me, *right_) >= 0);
			assert(myroot->compare(*right_, *me) <= 0);
		}
	} else {
		assert(parent_ == 0);
		assert(left_ == 0);
		assert(right_ == 0);
	}
}
TEST(MouseControllerUnitTest, CheckConstructor)
{
    Root * root = new Root;
    MouseController mc(root);
    EXPECT_EQ(root, mc.root_);
    root->release();
}
Example #5
0
void Inheritancetest::test_flush()
{
    Inheritance & i = Inheritance::instance();

    i.flush();

    // Make sure the type for root can no longer be retrieved
    const TypeNode * no_root_node = i.getType("root");
    assert(no_root_node == 0);
    const Root & non_root = i.getClass("root");
    assert(i.getAllObjects().empty());
    assert(!non_root.isValid());

    // Make sure installing a child of root now fails.
    Root r;
    r->setId("squigglymuff");
    r->setParents(std::list<std::string>(1, "root"));
    assert(i.addChild(r) == 0);

    assert(!i.hasClass("root"));
    assert(!i.hasClass("root_entity"));
    assert(!i.hasClass("root_operation"));
    assert(!i.hasClass("login"));
    assert(!i.hasClass("squigglymuff"));
}
Example #6
0
static void addTypeToList(const Root & type, ListType & typeList)
{
    typeList.push_back(type->getId());
    Element children;
    if (type->copyAttr("children", children) != 0) {
        return;
    }
    if (!children.isList()) {
        log(ERROR, compose("Type %1 children attribute has type %2 instead of "
                           "string.", type->getId(),
                           Element::typeName(children.getType())));
        return;
    }
    ListType::const_iterator I = children.List().begin();
    ListType::const_iterator Iend = children.List().end();
    for (; I != Iend; ++I) {
        Root child = Inheritance::instance().getClass(I->asString());
        if (!child.isValid()) {
            log(ERROR, compose("Unable to find %1 in inheritance table",
                               I->asString()));
            continue;
        }
        addTypeToList(child, typeList);
    }
}
Example #7
0
void Admin::createObject(const std::string & type_str,
                           const Root & arg,
                           const Operation & op,
                           OpVector & res)
{
    const std::string & objtype = arg->getObjtype();
    if (objtype == "class" || objtype == "op_definition") {
        // New entity type
        if (!arg->hasAttrFlag(Atlas::Objects::ID_FLAG)) {
            error(op, "Set arg has no id.", res, getId());
            return;
        }
        const std::string & id = arg->getId();

        if (Inheritance::instance().hasClass(id)) {
            error(op, "Attempt to install type that already exists", res,
                  getId());
            return;
        }
        const Root & o = Inheritance::instance().getClass(type_str);
        if (!o.isValid()) {
            error(op, compose("Attempt to install type with non-existant "
                              "parent \"%1\"", type_str), res, getId());
            return;
        }
        if (Ruleset::instance()->installRule(id, "unknown", arg) == 0) {
            Info info;
            info->setTo(getId());
            info->setArgs1(arg);
            res.push_back(info);
        } else {
            error(op, "Installing new type failed", res, getId());
        }
    } else if (type_str == "juncture") {
        std::string junc_id;
        long junc_iid = newId(junc_id);
        if (junc_iid < 0) {
            error(op, "Juncture failed as no ID available", res, getId());
            return;
        }

        Juncture * j = new Juncture(m_connection, junc_id, junc_iid);

        m_connection->addObject(j);
        m_connection->m_server.addObject(j);

        Anonymous info_arg;
        j->addToEntity(info_arg);

        Info info;
        info->setTo(getId());
        info->setArgs1(info_arg);
        if (!op->isDefaultSerialno()) {
            info->setRefno(op->getSerialno());
        }
        res.push_back(info);
    } else {
        Account::createObject(type_str, arg, op, res);
    }
}
Example #8
0
  void MarkSweepGC::collect(Roots &roots, CallFrameLocationList& call_frames) {
    Object* tmp;

    Root* root = static_cast<Root*>(roots.head());
    while(root) {
      tmp = root->get();
      if(tmp->reference_p()) {
        saw_object(tmp);
      }

      root = static_cast<Root*>(root->next());
    }

    // Walk all the call frames
    for(CallFrameLocationList::const_iterator i = call_frames.begin();
        i != call_frames.end();
        ++i) {
      CallFrame** loc = *i;
      walk_call_frame(*loc);
    }

    while(!mark_stack_.empty()) {
      tmp = mark_stack_.back();
      mark_stack_.pop_back();
      scan_object(tmp);
    }

    after_marked();
  }
Example #9
0
static int tryToConnect(PossessionClient& possessionClient)
{
    if (possessionClient.connectLocal(client_socket_name) == 0) {
        log(INFO, String::compose("Connected to server at %1.", client_socket_name));
        Root systemAccountResponse = possessionClient.createSystemAccount();
        if (!systemAccountResponse.isValid()) {
            return -2;
        }

        if (!systemAccountResponse->hasAttrFlag(Atlas::Objects::ID_FLAG)) {
            std::cerr << "ERROR: Logged in, but account has no id" << std::endl << std::flush;
        } else {

            int rulesCounter = 0;
            log(INFO, "Requesting rules from server");
            std::function<bool(const Atlas::Objects::Root&)> inheritenceFn = [&](const Atlas::Objects::Root& root) -> bool{
                Inheritance::instance().addChild(root);
                rulesCounter++;
                return true;
            };

            possessionClient.runTask(new RuleTraversalTask(systemAccountResponse->getId(), inheritenceFn), "game_entity");
            possessionClient.pollUntilTaskComplete();
            log(INFO, String::compose("Completed receiving %1 rules from server", rulesCounter));

            possessionClient.createAccount(systemAccountResponse->getId());
        }
        return 0;
    } else {
        return -1;
    }
}
    void createRenderWindow()
    {
		mRoot->initialise(false);

		{
			Ogre::String lWindowTitle = "Ballz";

			Ogre::ConfigFile cfgFile;
			cfgFile.loadDirect("config.ini");
			std::string wString = cfgFile.getSetting("width", "renderer");
			std::string hString = cfgFile.getSetting("height", "renderer");
			std::string fsString = cfgFile.getSetting("fullscreen", "renderer");
			int lSizeX = Ogre::StringConverter::parseInt(wString);
			int lSizeY = Ogre::StringConverter::parseInt(hString);
			int lFullscreen = Ogre::StringConverter::parseBool(fsString);

			Ogre::NameValuePairList lParams;
			// we use our own FXAA
			lParams["FSAA"] = "0"; 
			lParams["vsync"] = "false";

			lParams["useNVPerfHUD"] = "true";

			mWindow = mRoot->createRenderWindow(lWindowTitle, lSizeX, lSizeY, lFullscreen, &lParams);
		}	
    }
Example #11
0
 void setupRenderSystem()
 {
    if (!mRoot->restoreConfig() && !mRoot->showConfigDialog()) {
       throw Exception(52, "User canceled the config dialog!",
          "Application::setupRenderSystem()");
    }
 }
Example #12
0
void Game::startup(int width,int height,float scale)
{
	Root* root  = new Root("./main.cfg", "root.log");
	GLRenderSystem* render = new GLRenderSystem();
	root->setRender(render);
	

}
Example #13
0
WINTERMOON_BEGIN_NAMESPACE

EventListener::EventListener()
{
	Root* root = Root::instance();
	InputManager* input = root->inputManager();
	input->addListener(this);
}
    void setupRenderSystem()
    {

		const Ogre::RenderSystemList& lRenderSystemList = mRoot->getAvailableRenderers();
			Ogre::RenderSystem *lRenderSystem = lRenderSystemList[0];

			mRoot->setRenderSystem(lRenderSystem);
    }
    void createFrameListener()
    {
		mListener = new MainListener(mKeyboard, mMouse, mSceneMgr,m_World,mRoot,mWindow);
        mRoot->addFrameListener(mListener);
	    nListener = new NewtonListener(m_World );
		mRoot->addFrameListener(nListener);
	   
    }
Example #16
0
  MainListener(Root* root, OIS::Keyboard *keyboard) : mKeyboard(keyboard), mRoot(root) 
  {
    mProfessorNode = mRoot->getSceneManager("main")->getSceneNode("Professor");
    mFishNode = mRoot->getSceneManager("main")->getSceneNode("Fish");
	mFishPivot= mRoot->getSceneManager("main")->getSceneNode("Pivot");

	mFishPivot->setInheritOrientation(false);
  }
    void setupCEGUI()
    {
        SceneManager *mgr = mRoot->getSceneManager("Default SceneManager");
        RenderWindow *win = mRoot->getAutoCreatedWindow();

        // CEGUI setup
        mRenderer = new CEGUI::OgreCEGUIRenderer(win, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, mgr);
        mSystem = new CEGUI::System(mRenderer);
    }
Example #18
0
Root *Main::configRoot()
{
    Root *root = new Root();

    if (!root->restoreConfig())
        root->showConfigDialog();

    return root;
}
Example #19
0
void BaseMind::init(OpVector& res)
{
    Look look;
    Root lookArg;
    lookArg->setId(m_entityId);
    look->setArgs1(lookArg);
    look->setFrom(getId());
    res.push_back(look);
}
Example #20
0
Router::RouterResult Router::handleObject(const Root& obj)
{
    if (obj->instanceOf(Atlas::Objects::Operation::ROOT_OPERATION_NO))
        return handleOperation(smart_dynamic_cast<RootOperation>(obj));

    if (obj->instanceOf(Atlas::Objects::Entity::ROOT_ENTITY_NO))
        return handleEntity(smart_dynamic_cast<RootEntity>(obj));

    throw InvalidOperation("router got an object that is not an op or entity");
}
 LodWorkQueueWorker::~LodWorkQueueWorker()
 {
     Root* root = Root::getSingletonPtr();
     if (root) {
         WorkQueue* wq = root->getWorkQueue();
         if (wq) {
             wq->removeRequestHandler(mChannelID, this);
         }
     }
 }
Example #22
0
  void GarbageCollector::visit_roots(Roots& roots, ObjectVisitor& visit) {
    Root* root = static_cast<Root*>(roots.head());
    while(root) {
      Object* tmp = root->get();
      if(tmp->reference_p()) {
        visit.call(tmp);
      }

      root = static_cast<Root*>(root->next());
    }
  }
Example #23
0
TEST(Root,shutdown)
{
#ifdef OGRE_STATIC_LIB
    Root root("");
    OgreBites::StaticPluginLoader mStaticPluginLoader;
    mStaticPluginLoader.load();
#else
    Root root;
#endif
    root.shutdown();
}
Example #24
0
void Inheritancetest::test_addChild()
{
    Inheritance & i = Inheritance::instance();

    Root r;
    r->setId("squigglymuff");
    r->setParents(std::list<std::string>(1, "root_operation"));
    ASSERT_NOT_NULL(i.addChild(r));

    ASSERT_TRUE(i.hasClass("squigglymuff"));
}
Example #25
0
  Interval_root_stack(const Pd &p, Root lb, Root ub, Traits): lb_(lb),
							      ub_(ub) {
    CGAL_POLYNOMIAL_NS::Polynomial_converter<Pd, Pi, CGAL_POLYNOMIAL_NS::To_interval<double> > pc;
    CGAL_POLYNOMIAL_NS::Polynomial_converter<Pd, Pe, CGAL::NT_converter<double, ENT> > pce;
    p_=pc(p);
    pe_= pce(p);
    ok_=false;
    stack_.push_back(Root(std::numeric_limits<double>::infinity()));
    stack_.push_back(Root(lb.inf(), ub.sup()));
    refine();
  }
Example #26
0
void Inheritancetest::test_addChild_unknown_parent()
{
    Inheritance & i = Inheritance::instance();

    // Make sure inserting a type with unknown parents fails with null
    Root r;
    r->setId("squigglymuff");
    r->setParents(std::list<std::string>(1, "ludricous_test_parent"));
    ASSERT_NULL(i.addChild(r));

    ASSERT_TRUE(!i.hasClass("squigglymuff"));
}
Example #27
0
File: main.cpp Project: CCJY/coliru
int main()
{
    Root root;
    auto& interface = root.createChild<Interface>();
    auto& port1 = interface.createChild<Port>("trunk-1-1");
    port1.createChild<Ethernet>("00-ff-23-00-00-01");
    port1.createChild<IPv4>("1.1.1.1");
    port1.createChild<HTTP>();
    port1.createChild<HTTP>();

    root.destroy();
}
Example #28
0
void Admin::setAttribute(const Root& args) {
    //If the attribute "possessive" is set on the account it will control whether this
    //account acts as an external minds connection.
    if (args->hasAttr("possessive")) {
        const Element possessiveElement = args->getAttr("possessive");
        if (possessiveElement.isInt() && possessiveElement.asInt() != 0) {
            m_connection->setPossessionEnabled(true, getId());
        } else {
            m_connection->setPossessionEnabled(false, getId());
        }
    }
}
TEST(FocusControllerUnitTest, CheckConstructor)
{
    Root * root = new Root;
    FocusController fc(root);
    EXPECT_EQ(root, fc.root_);
    EXPECT_EQ(nullptr, fc.current_);
    EXPECT_EQ(nullptr, fc.wait_focus_);
    EXPECT_FALSE(fc.has_focus_);
    EXPECT_EQ(FocusController::kTraversal, fc.reason_);
    EXPECT_FALSE(fc.arrow_key_traversal_enabled_);
    root->release();
}
Example #30
0
/** It does this with 'kza' by matching the first argument, and then by
    searching that object's MixCompRef references for the next component of
    this mixture that contains this root. The last match is indicated by the
    third argument (and the 'this' pointer).  The reference argument
    (double&) is updated with the density of the root isotope in the
    appropriate component, when the match is found. */
Component* Mixture::getComp(int kza,double &density, Component *lastComp)
{
  Root *root = rootList->find(kza);

  if (root)
    return root->getComp(density,this,lastComp);
  else
    {
      density = 0;
      return NULL;
    }
}