コード例 #1
0
ファイル: lookupTypes.cpp プロジェクト: sebkirche/strongtalk
char* lookupTypeName(LookupType l) {
  char* name = NEW_RESOURCE_ARRAY(char, 80);
  switch (withoutExtraBits(l)) {
   case NormalLookupType:
    strcpy(name, "NormalLookup");
    break;
   case SelfLookupType:
    strcpy(name, "SelfLookup");
    break;
   case SuperLookupType:
    strcpy(name, "SuperLookup");
    break;
   default:
    fatal("Unknown lookupType");
   }
  bool hasFlag = false;
  switch (countType(l)) {
   case NonCounting: break;
   case Counting:    addFlag(hasFlag, name, "counting "); break;
   case Comparing:   addFlag(hasFlag, name, "comparing "); break;
   default: 	     fatal1("invalid count type %ld", countType(l));
  }
  if (isSet(l, DirtySendBit)) addFlag(hasFlag, name, "dirty ");
  if (isSet(l, OptimizedSendBit)) addFlag(hasFlag, name, "optimized ");
  if (isSet(l, UninlinableSendBit)) addFlag(hasFlag, name, "uninlinable ");
  if (hasFlag) strcat(name, "}");
    
  return name;
}
コード例 #2
0
 void setTrasformationFlags(){
     addFlag(Flag("r", "min-alph",
                  "Minimal Alphabet Size",
                  INT, &settings::MIN_ALHPABET_SIZE));
     addFlag(Flag("R", "max-alph",
                  "Maximum Alphabet Size",
                  INT, &settings::MAX_ALHPABET_SIZE));
 }
コード例 #3
0
    void setLogFlags(){
        /* ------ LOGGER ----- */

        addFlag(Flag("D", "log-main-dir",
                     "Main directory to store all logs",
                     STRING,
                     &settings::LOG_MAIN_DIR));
        addFlag(Flag("d", "log-dir",
                     "directory to store logs of current computations",
                     STRING,
                     &settings::LOG_CURR_DIR));
    }
コード例 #4
0
ファイル: StaticBrush.cpp プロジェクト: nikki93/grall2
//--- NGF events ----------------------------------------------------------------
StaticBrush::StaticBrush(Ogre::Vector3 pos, Ogre::Quaternion rot, NGF::ID id, NGF::PropertyList properties, Ogre::String name)
    : NGF::GameObject(pos, rot, id , properties, name)
{
    addFlag("StaticBrush");

    //Python init event.
    NGF_PY_CALL_EVENT(init);

    //Get properties.
    bool convex = Ogre::StringConverter::parseBool(mProperties.getValue("convex", 0, "no"));

    //Create the Ogre stuff.
    mEntity = createBrushEntity();
    mNode = GlbVar.ogreSmgr->getRootSceneNode()->createChildSceneNode(mOgreName, pos, rot);
    mNode->attachObject(mEntity);

    //Create the Physics stuff.
    BtOgre::StaticMeshToShapeConverter converter(mEntity);

    if (convex)
    {
        mShape = converter.createConvex();
        mShape->setMargin(0);
    }
    else
        mShape = converter.createTrimesh();

    BtOgre::RigidBodyState *state = new BtOgre::RigidBodyState(mNode);
    mBody = new btRigidBody(0, state, mShape, btVector3(0,0,0));
    initBody( DimensionManager::STATIC
            );
}
コード例 #5
0
	ProgramFlags BillboardBase::getProgramFlags()const
	{
		ProgramFlags result = uint32_t( ProgramFlag::eBillboards );

		if ( m_billboardType == BillboardType::eSpherical )
		{
			addFlag( result, ProgramFlag::eSpherical );
		}

		if ( m_billboardSize == BillboardSize::eFixed )
		{
			addFlag( result, ProgramFlag::eFixedSize );
		}

		return result;
	}
コード例 #6
0
ファイル: WarManager.cpp プロジェクト: acekiller/CameraGame
//------------------------------------------------
void WarManager::endWar()
{

	addFlag(F_EndWar);
    removeFlag(F_InWar);
 
    return ;
}
コード例 #7
0
ファイル: WarManager.cpp プロジェクト: acekiller/CameraGame
//-------------------------------------------------
void WarManager::startWar()
{

    addFlag(F_InWar);
	init();

    return ;
}
コード例 #8
0
ファイル: AIMove.cpp プロジェクト: MusicAdam/Chess
/*
///These are the flags assigned to the moves that the AI parses
        ///A move can have multiple flags
        enum {
            MOVE_STRATEGIC, ///This move would serve to strategically position a piece for future ATTACK/DEFENSE moves.
                                ///This move will take priority if no other pressing ATTACK/DEFENSE moves are possible

            MOVE_ATTACK,        ///This move would jump an enemy piece

            MOVE_DEFENSE,       ///This move would docourage an enemy piece from jumping a friendly piece, IE
                                ///     if the enemy piece were to jump the friendly piece, this piece would be
                                ///     be in position to attack it.

            MOVE_SUICIDE,       ///This move would move the piece in such a way that it could be jumped next turn
            MOVE_RETREAT,        ///This move removes the piece from danger
            MOVE_BREAK          ///This move would cause another piece to be left defenseless
        };
*/
void AIMove::setFlags(){
    if(move.isAttackMove()){
        addFlag(MOVE_ATTACK);
    }else if(move.isDefaultMove()){
        //Check for defensive move

        //Check if piece would be able to jump friendly piece (as in, if the enemy piece were to jump the firendly piece, would this move allow the piece to jump back)
       //MoveData testMove(move.pieceType, move.pieceIndex);
    }
}
コード例 #9
0
ファイル: dialog.cpp プロジェクト: woronin/kumir2
Dialog::Dialog(QWidget* parent, Qt::WindowFlags fl ): QDialog ( parent, fl ), Ui::Dialog()
{
setupUi(this);
connect(BaseA,SIGNAL(valueChanged ( int  )),this,SLOT(setMax()));
connect(BaseB,SIGNAL(valueChanged ( int  )),this,SLOT(setMax()));
connect(pushButton,SIGNAL(clicked(   )),this,SLOT(addFlag()));
connect(pushButton_2,SIGNAL(clicked(   )),this,SLOT(removeFlag()));
connect(listWidget,SIGNAL(itemClicked (QListWidgetItem*)),this,SLOT(enableDelete()));
    translateButtons();
};
コード例 #10
0
ファイル: vcardfactory.cpp プロジェクト: NeutronStein/jreen
	VCardAddressParser() : StructurePrivateParser<VCard::AddressPrivate, VCard::Address>(QLatin1String("ADR"))
	{
		QString *strings[] = {
			&m_data.pobox, &m_data.extendedAddress, &m_data.street,
			&m_data.locality, &m_data.region, &m_data.pcode,
			&m_data.country
		};
		for (int i = 0, size = sizeof(strings)/sizeof(QString*); i < size; i++)
			addString(QLatin1String(vcardAddressFields[i]), strings[i]);
		addFlag(vcardAddressTypes, &m_data.types);
	}
コード例 #11
0
void FlagList::load(KConfig *config)
{
  _flags.clear(); 
  int num = config->readNumEntry("Flags", 0);

  for (int i=0; i<num; ++i)
    {
      addFlag(new Flag(config->readDoubleNumEntry(QString("Flag_%1_Longitude").arg(i)),
		       config->readDoubleNumEntry(QString("Flag_%1_Latitude").arg(i)),
		       config->readColorEntry(QString("Flag_%1_Color").arg(i))));
    }
}
コード例 #12
0
void MenuMonteCarlo::specify() { 


  ///
  _FLG_MCSEED = 
    new ConfigFlag<int>(eoValueParam<int>(
			  0,
			  "mcseed",
			  "seed for montecarlo data samples, 0: totally random",
			  0,
			  false),
			(Condition *) 0);

  ///
  _FLG_NMONTS = 
    new ConfigFlag<int>(eoValueParam<int>(
			  DEF_NMONTS,
			  "nmonts",
			  "# of Monte Carlo data samples",
			  0,
			  true),
			(Condition *) 0);


 /// 
 _FLG_MCSTDDIV = 
   new ConfigFlag<double>(eoValueParam<double>(
			    0,
			    "mcstddiv",
			    "standard div. of errors in data samples",
			    0,
			    false),
			 (Condition *) 0);


  addFlag(_FLG_NMONTS);
  addFlag(_FLG_MCSEED);
  addFlag(_FLG_MCSTDDIV);

}
コード例 #13
0
ファイル: main.c プロジェクト: SRWieZ/MinesweeperC
// Permet de poser un drapeau
void putFlag(int x, int y)
{
	// On execute le contenue seulement si la case n'a pas été minée
	if(isMined(x, y) == FALSE)
	{
		// On vérifie qu'il n'y a pas déjà un drapeau
		if(isFlag(x, y) == FALSE)
		{
			// On vérifie que l'on a pas mis plus de drapeau que de bombes
			if(nbFlags < NB_BOMBS)
			{
				// On choisit nos couleurs
				textbackground(B_FLAG);
				textcolor(C_FLAG);

				// On affiche le drapeau
				printf("%c", A_FLAG);

				// On ajoute le drapeau à la liste
				addFlag(x, y);
			}
			else
			{
				// On affiche une erreur
				msgZone(C_WARNING, B_WARNING);
				printf("You can't use more");
				gotoxy(mapX+OFFSET_X+(BORDER*2), OFFSET_Y+18);
				printf("than %d flags", NB_BOMBS);
			}
		}
		else // Sinon on enlève le drapeau existant
		{
			// On choisit nos couleurs
			textbackground(B_MAP);
			textcolor(C_MAP);

			// On remet un case non miné
			printf("%c", A_MAP);

			// On enleve le drapeau du tableau
			removeFlag(x, y);
		}
	}
}
コード例 #14
0
ファイル: Pickup.cpp プロジェクト: brownman/grall2
//--- NGF events ----------------------------------------------------------------
Pickup::Pickup(Ogre::Vector3 pos, Ogre::Quaternion rot, NGF::ID id, NGF::PropertyList properties, Ogre::String name)
    : NGF::GameObject(pos, rot, id , properties, name),
      mTime(0)
{
    addFlag("Pickup");

    //Python init event.
    NGF_PY_CALL_EVENT(init);
    NGF_PY_SAVE_EVENT(pickedUp);

    //Store properties.
    mPickupType = mProperties.getValue("pickupType", 0, "KeyR");
    mSpin = Ogre::Math::DegreesToRadians(Ogre::StringConverter::parseReal(mProperties.getValue("spin", 0, "0")));
    mBobAmp = Ogre::StringConverter::parseReal(mProperties.getValue("bobAmplitude", 0, "0"));
    mBobVel = 2 * Ogre::Math::PI * Ogre::StringConverter::parseReal(mProperties.getValue("bobFrequency", 0, "0"));

    //Create the Ogre stuff. Pickups can be brushes too. :-)
    if (mProperties.getValue("brushMeshFile", 0, "n") == "n")
    {
        Ogre::String meshFile = mProperties.getValue("meshFile", 0, "Mesh_Key.mesh");
        Ogre::String material = mProperties.getValue("material", 0, "Objects/KeyR");
        mEntity = GlbVar.ogreSmgr->createEntity(mOgreName, meshFile);
        mEntity->setMaterialName(material);
    }
    else
    {
        mEntity = createBrushEntity();
    }
    mNode = GlbVar.ogreSmgr->getRootSceneNode()->createChildSceneNode(mOgreName, pos, rot);

    mChildNode = mNode->createChildSceneNode(mOgreName + "_child");
    mChildNode->attachObject(mEntity);

    //Create the Physics stuff.
    BtOgre::StaticMeshToShapeConverter converter(mEntity);
    mShape = converter.createConvex();

    BtOgre::RigidBodyState *state = new BtOgre::RigidBodyState(mNode);
    mBody = new btRigidBody(0, state, mShape, btVector3(0,0,0));
    initBody( DimensionManager::NO_DIM_CHECK
            | DimensionManager::NO_BULLET_HIT
            );
    mBody->setCollisionFlags(mBody->getCollisionFlags() | btCollisionObject::CF_NO_CONTACT_RESPONSE);
}
コード例 #15
0
ファイル: CFObject.cpp プロジェクト: uvbs/GameProject
	void IRenderNode::setRenderOption( RenderOption option , DWORD val )
	{
		switch ( option )
		{
		case CFRO_Z_TEST :
			val = ( val ) ? D3DZB_TRUE : D3DZB_FALSE; 
			break;
		case CFRO_ZBIAS :
			{			
				float bias = 0.1f * val;
				val = *((DWORD*)&bias);
			}
			break;
		case CFRO_SRC_BLEND :
		case CFRO_DEST_BLEND :
			val = D3DTypeMapping::convert( BlendMode(val) );
			break;
		case CFRO_ALPHA_BLENGING :
			if ( val )
				addFlag( NODE_TRANSLUCENT_OBJ );
			else
				removeFlag( NODE_TRANSLUCENT_OBJ );
			break;
		case CFRO_CULL_FACE:
			val = D3DTypeMapping::convert( CullFace( val ) );
			break;
		case CFRO_Z_BUFFER_WRITE :
		case CFRO_LIGHTING :
		case CFRO_FOG :
			break;

		default:
			assert(0);
		}

		if ( D3DTypeMapping::getDefaultValue( option ) == val )
			mUsageRenderOption &= ~ BIT( option );
		else
			mUsageRenderOption |= BIT( option );

		mRenderOption[ option ] = val;
	}
コード例 #16
0
ファイル: OneWay.cpp プロジェクト: nikki93/grall2
//--- NGF events ----------------------------------------------------------------
OneWay::OneWay(Ogre::Vector3 pos, Ogre::Quaternion rot, NGF::ID id, NGF::PropertyList properties, Ogre::String name)
    : NGF::GameObject(pos, rot, id , properties, name)
{
    addFlag("OneWay");

    //Python init event.
    NGF_PY_CALL_EVENT(init);

    //Create the Ogre stuff.

    if (mProperties.getValue("brushMeshFile", 0, "n") == "n")
    {
        mEntity = GlbVar.ogreSmgr->createEntity(mOgreName, "OneWay.mesh");

        BtOgre::StaticMeshToShapeConverter converter(mEntity);
        mShape = converter.createBox();
    }
    else
    {
        mEntity = createBrushEntity();

        BtOgre::StaticMeshToShapeConverter converter(mEntity);
        mShape = converter.createTrimesh();
        mShape->setMargin(0);
    }
    mEntity->setMaterialName("Objects/OneWay");

    mNode = GlbVar.ogreSmgr->getRootSceneNode()->createChildSceneNode(mOgreName, pos, rot);
    mNode->attachObject(mEntity);

    //Create the Physics stuff.
    BtOgre::RigidBodyState *state = new BtOgre::RigidBodyState(mNode);
    mBody = new btRigidBody(0, state, mShape, btVector3(0,0,0));
    initBody( DimensionManager::NO_DIM_CHECK
              | DimensionManager::NO_CRATE_CHECK
              | DimensionManager::NO_MOVING_CHECK
              | DimensionManager::NO_BULLET_HIT
            );
    mBody->setCollisionFlags(mBody->getCollisionFlags() | btCollisionObject::CF_NO_CONTACT_RESPONSE);
}
コード例 #17
0
ファイル: kinds.cpp プロジェクト: AdamSpitz/self
char* lookupTypeName(LookupType l) {
  char* name = NEW_RESOURCE_ARRAY(char, 80);
  switch (l) {
   case NormalLookupType:
    strcpy(name, "NormalLookup");
    break;
   case StaticNormalLookupType:
    strcpy(name, "StaticNormalLookup");
    break;
   case ImplicitSelfLookupType:
    strcpy(name, "ImplicitSelfLookup");
    break;
   case ResendLookupType:
    strcpy(name, "ResendLookup");
    break;
   case DirectedResendLookupType:
    strcpy(name, "DirectedResendLookup");
    break;
   case NormalPerformType:
    strcpy(name, "NormalPerform");
    break;
   case ResendPerformType:
    strcpy(name, "ResendPerform");
    break;
   case DelegatedPerformType:
    strcpy(name, "DelegatedPerform");
    break;
   default:
    char* baseName;
    switch (baseLookupType(l)) {
     case NormalBaseLookupType:
      baseName ="NormalBaseLookup "; break;
     case ResendBaseLookupType:
      baseName ="ResendBaseLookup "; break;
     case DirectedResendBaseLookupType:
      baseName ="DirectedResendBaseLookup "; break;
     case DelegatedBaseLookupType:
      baseName ="DelegatedBaseLookup "; break;
     default: fatal("unexpected base lookup type");
    }
    strcpy(name, baseName);
    if (l & SelectorStaticBit) {
      strcat(name, "<selector static> ");
    }
    if (l & DelegateeStaticBit) {
      strcat(name, "<delegatee static> ");
    }
    if (l & ReceiverStaticBit) {
      strcat(name, "<receiver map static> ");
    }
  }
  bool hasFlag = false;
  switch (countType(l)) {
   case NonCounting: break;
   case Counting:    addFlag(hasFlag, name, "counting "); break;
   case Comparing:   addFlag(hasFlag, name, "comparing "); break;
   default:          fatal1("invalid count type %ld", countType(l));
  }
  if (isSet(l, DirtySendBit)) addFlag(hasFlag, name, "dirty ");
  if (isSet(l, OptimizedSendBit)) addFlag(hasFlag, name, "optimized ");
  if (isSet(l, UninlinableSendBit)) addFlag(hasFlag, name, "uninlinable ");
  if (hasFlag) strcat(name, "}");
    
  return name;
}
コード例 #18
0
ファイル: uptime.cpp プロジェクト: Alexis211/Melon
	uptime() : ShellApp("uptime", "Get the system's uptime") {
		addFlag("u", "unformatted", "Show raw number of seconds", FT_BOOL, "");
	}
コード例 #19
0
ファイル: Crate.cpp プロジェクト: brownman/grall2
//--- NGF events ----------------------------------------------------------------
Crate::Crate(Ogre::Vector3 pos, Ogre::Quaternion rot, NGF::ID id, NGF::PropertyList properties, Ogre::String name)
    : NGF::GameObject(pos, rot, id , properties, name),
      mMoving(false),
      mExploded(false)
{
    addFlag("Crate");
    addFlag("Switcher");

    Ogre::String script = mProperties.getValue("script", 0, "");

    //Python init event.
    NGF_PY_CALL_EVENT(init);

    //Read properties.
    Ogre::Real heightDef = Ogre::StringConverter::parseReal(mProperties.getValue("heightDeficiency", 0, "0"));

    if(!(mProperties.getValue("NGF_SERIALISED", 0, "no") == "yes"))
        pos.y -= heightDef * 0.5; //If deficient in height, move down by half the deficiency because midpoint is local origin.

    //Create the Ogre stuff.
    mEntity = GlbVar.ogreSmgr->createEntity(mOgreName, "Crate.mesh");
    mNode = GlbVar.ogreSmgr->getRootSceneNode()->createChildSceneNode(mOgreName, pos, rot);
    mNode->attachObject(mEntity);

    //Create the Physics stuff. The mesh is a normal box, except in the bottom it's bevelled.
    Ogre::Entity *colMesh = GlbVar.ogreSmgr->createEntity(mOgreName + "_Collision", "Collision_Crate.mesh");
    BtOgre::StaticMeshToShapeConverter converter(colMesh);
    mShape = converter.createConvex();
    GlbVar.ogreSmgr->destroyEntity(colMesh);

    mShape->setMargin(0);
    btScalar mass = 7;
    btVector3 inertia;
    mShape->calculateLocalInertia(mass, inertia);

    BtOgre::RigidBodyState *state = new BtOgre::RigidBodyState(mNode);
    btRigidBody::btRigidBodyConstructionInfo info(mass, state, mShape, inertia);

    mBody = new btRigidBody(info);
    mBody->setActivationState(DISABLE_DEACTIVATION);
    initBody( DimensionManager::LIFTABLE
            );

    //To allow Gravity, but still constraint on XZ plane, we use slider.
    mCastShape = new btBoxShape(btVector3(0.475,0.65,0.475));

    btDefaultMotionState *fixedState = new btDefaultMotionState(btTransform(BtOgre::Convert::toBullet(rot), BtOgre::Convert::toBullet(pos + Ogre::Vector3(0,20,0))));
    mFixedBody = new btRigidBody(0, fixedState, mCastShape);
    mFixedBody->setCollisionFlags(mBody->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT | btCollisionObject::CF_NO_CONTACT_RESPONSE);
    mFixedBody->setActivationState(DISABLE_DEACTIVATION);
    GlbVar.phyWorld->addRigidBody(mFixedBody, mDimensions 
            | DimensionManager::NO_DIM_CHECK 
            | DimensionManager::NO_MOVING_CHECK 
            | DimensionManager::NO_BULLET_HIT 
            | DimensionManager::NO_CRATE_CHECK 
            | DimensionManager::INVISIBLE
            , mDimensions);

    mConstraint = new btSliderConstraint(*mBody, *mFixedBody, btTransform(btQuaternion(btVector3(0,0,1),Ogre::Math::PI/2.0)), btTransform(btQuaternion(btVector3(0,0,1),Ogre::Math::PI/2.0)), false);
    mConstraint->setLowerLinLimit(1); //Free linear.
    mConstraint->setUpperLinLimit(0);
    mConstraint->setLowerAngLimit(0); //Locked angular.
    mConstraint->setUpperAngLimit(0);
    //mConstraint->setRestitutionOrthoLin(3);

    mBody->setAngularFactor(btVector3(0,0,0));
    mBody->setLinearFactor(btVector3(0,1,0));

    //GlbVar.phyWorld->addConstraint(mConstraint, true);

    //Height deficiency, for some variety in Crates.
    mHeight = 1.5 - heightDef;
    if (heightDef != 0)
    {
        Ogre::Real scale = mHeight / 1.5;
        mNode->setScale(Ogre::Vector3(1,scale,1));
        mShape->setLocalScaling(btVector3(1,scale,1));
        mCastShape->setLocalScaling(btVector3(1,scale,1));
    }

    //Crate materials, again for variety.
    int n = Ogre::Math::Floor(Ogre::Math::RangeRandom(1, MAX_CRATE_MATERIALS + 0.99));
    mEntity->setMaterialName("Objects/Crate" + Ogre::StringConverter::toString(n));

    //Sound.
    mSound = GlbVar.soundMgr->createSound(mOgreName + "_Sound", "CrateMove.ogg", true, false);
    mNode->attachObject(mSound);
    mSound->setReferenceDistance(1.2);
    mSound->setGain(2.1);
}
コード例 #20
0
ファイル: flags.cpp プロジェクト: CoryMcCartan/chapel
void addFlag(BaseAST* ast, Flag flag)    { addFlag(ast, (int)flag); }
コード例 #21
0
ファイル: vcardfactory.cpp プロジェクト: NeutronStein/jreen
	VCardTelParser() : StructurePrivateParser<VCard::TelephonePrivate, VCard::Telephone>(QLatin1String("TEL"))
	{
		addString(QLatin1String("NUMBER"), &m_data.number);
		addFlag(vcardTelTypes, &m_data.types);
	}
コード例 #22
0
ファイル: vcardfactory.cpp プロジェクト: NeutronStein/jreen
	VCardEMailParser() : StructurePrivateParser<VCard::EMailPrivate, VCard::EMail>(QLatin1String("EMAIL"))
	{
		addString(QLatin1String("USERID"), &m_data.userId);
		addFlag(vcardEMailTypes, &m_data.types);
	}
コード例 #23
0
ファイル: FlagParser.cpp プロジェクト: Zwackelmann/mws
int
FlagParser::parse(const int   argc,
                  char* const argv[])
{
    map<char, FlagOpt> :: iterator it;
    vector<struct option>          longOpts;
    string                         optString;
    char                           ch;
    struct option                  currentOpt;
    const struct option            zeroOpt = {0, 0, 0, 0};
    int                            optIndex;

    // Add help and verbose flags
    addFlag('h', "help", FLAG_OPT, ARG_NONE);
    addFlag('v', "verbose", FLAG_OPT, ARG_NONE);

    // Storing program name
    _progName = argv[0];

    // Building optString and longOpts
    optString = "+"; // Setting POSIXLY_CORRECT ON

    for (it = _flagOpts.begin(); it != _flagOpts.end(); it++)
    {
        optString += it->first;
        if (it->second.argMandatory == ARG_REQ)
        {
            optString += ":";
        }
        else if (it->second.argMandatory == ARG_OPT)
        {
            optString += "::";
        }

        currentOpt.name    = it->second.longOpt.c_str();
        currentOpt.has_arg = it->second.argMandatory;
        currentOpt.flag    = 0;
        currentOpt.val     = it->first;

        longOpts.push_back(currentOpt);
    }

    // Adding a 0 fill element
    longOpts.push_back(zeroOpt);

    while ((ch = getopt_long(argc, argv,
                             optString.c_str(),
                             longOpts.data(),
                             &optIndex))
            != -1)
    {
        // Handle -h / --help
        if (ch == 'h') {
            fprintf(stdout, "%s", getUsage().c_str());
            exit(EXIT_SUCCESS);
        }

        // Handle -v / --verbose
        if (ch == 'v') {
            fprintf(stdout, "%s: verbose mode\n", argv[0]);
            verbose = true;
        }

        // Record flags (and arguments)
        if ((it = _flagOpts.find(ch))
                != _flagOpts.end())
        {
            it->second.parsed = true;
            switch(it->second.argMandatory)
            {
            case ARG_NONE:
                _parsedArgs.insert(make_pair(ch, vector<string>()));
                break;
            case ARG_OPT:
                if (optarg == NULL) continue;
                _parsedArgs[ch].push_back(optarg);
                break;
            case ARG_REQ:
                if (optarg == NULL) goto failure;
                _parsedArgs[ch].push_back(optarg);
                break;

            default:
                assert(0);
            }
        }
        else
        {
            goto failure;
        }
    }

    /* Parse params */
    while (optind < argc) {
        _params.push_back(argv[optind++]);
    }

    // Check if all mandatory arguments were parsed
    for (it = _flagOpts.begin(); it != _flagOpts.end(); it++)
    {
        if (it->second.optMandatory == FLAG_REQ &&
            !it->second.parsed)
        {
            fprintf(stderr, "%s: option -%c|--%s is required\n",
                    argv[0], it->first, it->second.longOpt.c_str());
            goto failure;
        }
    }

    // Check if number of params is valid
    if (_minNumParams == -1 && _params.size() != 0) {
        fprintf(stderr, "%s: No params are allowed\n", argv[0]);
        goto failure;
    } else if (_minNumParams > 0 && _params.size() < (size_t) _minNumParams) {
        fprintf(stderr, "%s: At least %d params are required\n",
                argv[0], _minNumParams);
        goto failure;
    }

    return 0;

failure:
    return -1;
}
コード例 #24
0
ファイル: attrib.c プロジェクト: apriori/dsss
void PragmaDeclaration::semantic(Scope *sc)
{   // Should be merged with PragmaStatement

    //printf("\tPragmaDeclaration::semantic '%s'\n",toChars());
    /*if (ident == Id::msg)
    {
	if (args)
	{
	    for (size_t i = 0; i < args->dim; i++)
	    {
		Expression *e = (Expression *)args->data[i];

		e = e->semantic(sc);
		e = e->optimize(WANTvalue | WANTinterpret);
		if (e->op == TOKstring)
		{
		    StringExp *se = (StringExp *)e;
		    fprintf(stdmsg, "%.*s", (int)se->len, se->string);
		}
		else
		    error("string expected for message, not '%s'", e->toChars());
	    }
	    fprintf(stdmsg, "\n");
	}
	goto Lnodecl;
    }
    else if (ident == Id::lib)
    {
	if (!args || args->dim != 1)
	    error("string expected for library name");
	else
	{
	    Expression *e = (Expression *)args->data[0];

	    e = e->semantic(sc);
	    e = e->optimize(WANTvalue | WANTinterpret);
	    args->data[0] = (void *)e;
	    if (e->op != TOKstring)
		error("string expected for library name, not '%s'", e->toChars());
	    else if (global.params.verbose)
	    {
		StringExp *se = (StringExp *)e;
		char *name = (char *)mem.malloc(se->len + 1);
		memcpy(name, se->string, se->len);
		name[se->len] = 0;
		printf("library   %s\n", name);
		mem.free(name);
	    }
	}
	goto Lnodecl;
    }
#if IN_GCC
    else if (ident == Id::GNU_asm)
    {
	if (! args || args->dim != 2)
	    error("identifier and string expected for asm name");
	else
	{
	    Expression *e;
	    Declaration *d = NULL;
	    StringExp *s = NULL;

	    e = (Expression *)args->data[0];
	    e = e->semantic(sc);
	    if (e->op == TOKvar)
	    {
		d = ((VarExp *)e)->var;
		if (! d->isFuncDeclaration() && ! d->isVarDeclaration())
		    d = NULL;
	    }
	    if (!d)
		error("first argument of GNU_asm must be a function or variable declaration");

	    e = (Expression *)args->data[1];
	    e = e->semantic(sc);
	    e = e->optimize(WANTvalue);
	    if (e->op == TOKstring && ((StringExp *)e)->sz == 1)
		s = ((StringExp *)e);
	    else
		error("second argument of GNU_asm must be a char string");

	    if (d && s)
		d->c_ident = Lexer::idPool((char*) s->string);
	}
	goto Lnodecl;
    }
#endif
    else if (ident == Id::startaddress)
    {
	if (!args || args->dim != 1)
	    error("function name expected for start address");
	else
	{
	    Expression *e = (Expression *)args->data[0];
	    e = e->semantic(sc);
	    e = e->optimize(WANTvalue | WANTinterpret);
	    args->data[0] = (void *)e;
	    Dsymbol *sa = getDsymbol(e);
	    if (!sa || !sa->isFuncDeclaration())
		error("function name expected for start address, not '%s'", e->toChars());
	}
	goto Lnodecl;
    }
    else if (global.params.ignoreUnsupportedPragmas)
    {
	if (global.params.verbose)
	{
	    / * Print unrecognized pragmas
	     * /
	    printf("pragma    %s", ident->toChars());
	    if (args)
	    {
		for (size_t i = 0; i < args->dim; i++)
		{
		    Expression *e = (Expression *)args->data[i];
		    e = e->semantic(sc);
		    e = e->optimize(WANTvalue | WANTinterpret);
		    if (i == 0)
			printf(" (");
		    else
			printf(",");
		    printf("%s", e->toChars());
		}
		if (args->dim)
		    printf(")");
	    }
	    printf("\n");
	}
	goto Lnodecl;
    }
    else
	error("unrecognized pragma(%s)", ident->toChars()); */
    
    if (ident == Id::link)
    {
	if (args)
	{
	    for (size_t i = 0; i < args->dim; i++)
	    {
		Expression *e = (Expression *)args->data[i];

		e = e->semantic(sc);
                e = e->optimize(WANTvalue | WANTinterpret);
		if (e->op == TOKstring)
		{
		    StringExp *se = (StringExp *)e;
                    linkLibrary((char *) se->string);
		}
		else
		    error("string expected for link, not '%s'", e->toChars());
	    }
	}
	goto Lnodecl;
        
    } else if (ident == Id::export_version) {
	if (args)
	{
	    for (size_t i = 0; i < args->dim; i++)
	    {
		Expression *e = (Expression *)args->data[i];
  
                char *toadd = NULL;
                
		e = e->semantic(sc);
                e = e->optimize(WANTvalue | WANTinterpret);
		if (e->op == TOKstring)
		{
		    StringExp *se = (StringExp *)e;
                    toadd = (char *) se->string;
                }
                else if (e->op == TOKidentifier)
                {
                    toadd = e->toChars();
                }
                else
                    error("string or identifier expected for export_version, not '%s'", e->toChars());
                
                /* add this version flag to our own idea of versions, as
                 * well as the compile line */
                VersionCondition::addPredefinedGlobalIdent(toadd);
                addFlag(compileFlags, "compile", "version", "-version=$i", toadd);
            }
        }
        
    } else if (ident == Id::nolink) {
        if (sc && sc->module) {
            sc->module->nolink = 1;
        }
        
    }

    return;

Lnodecl:
    if (decl)
	error("pragma is missing closing ';'");
}
コード例 #25
0
ファイル: TemplateEngine.cpp プロジェクト: jaccen/liblub
void TemplateEngine::addFlags(const vector<string> & flags) {
    foreach (string flag, flags)
        addFlag(flag);
}
コード例 #26
0
ファイル: SimpleGuiRun.cpp プロジェクト: lssfau/walberla
int main(int argc, char **argv )
{
   walberla::Environment env( argc, argv );

   const uint_t cells [] = { 6,5,3 };
   const uint_t blockCount [] = { 4, 3,2 };
   const uint_t nrOfTimeSteps = 20;

   // Create BlockForest
   auto blocks = blockforest::createUniformBlockGrid(blockCount[0],blockCount[1],blockCount[2],  //blocks
                                        cells[0],cells[1],cells[2], //cells
                                        1,                          //dx
                                        false,                      //one block per process
                                        true,true,true);            //periodicity

   LatticeModel latticeModel( lbm::collision_model::SRT(1.5 ) );

   // In addition to the normal GhostLayerField's  we allocated additionally a field containing the whole global simulation domain for each block
   // we can then check if the GhostLayer communication is correct, by comparing the small field to the corresponding part of the big field

   BlockDataID pdfField     = lbm::addPdfFieldToStorage( blocks, "PdfField", latticeModel );

   BlockDataID scalarField1 = field::addToStorage<ScalarField>( blocks, "ScalarFieldOneGl", real_t(0), field::zyxf,  1 );
   BlockDataID scalarField2 = field::addToStorage<ScalarField>( blocks, "ScalarFieldTwoGl", real_t(0), field::zyxf,  2 );
   BlockDataID vectorField  = field::addToStorage<VectorField>( blocks, "VectorField", Vector3<real_t>(0,0,0) );
   BlockDataID flagField    = field::addFlagFieldToStorage<FField>( blocks, "FlagField" );


   // Init src field with some values
   for( auto blockIt = blocks->begin(); blockIt != blocks->end(); ++blockIt ) // block loop
   {
      // Init PDF field
      PdfField * src = blockIt->getData<PdfField>(pdfField);
      for( auto cellIt = src->begin(); cellIt != src->end(); ++cellIt ) // over all x,y,z,f
      {
         Cell cell ( cellIt.x(), cellIt.y(), cellIt.z() );
         blocks->transformBlockLocalToGlobalCell(cell, *blockIt);
         *cellIt = real_c( ( cell[0] + cell[1] + cell[2] + cellIt.f() ) % cell_idx_t(42) );
      }

      // Init scalarField1
      ScalarField * sf = blockIt->getData<ScalarField> ( scalarField1 );
      for( auto cellIt = sf->beginWithGhostLayer(); cellIt != sf->end(); ++cellIt ) // over all x,y,z
      {
         Cell cell ( cellIt.x(), cellIt.y(), cellIt.z() );
         blocks->transformBlockLocalToGlobalCell(cell, *blockIt);
         *cellIt = real_c( ( cell[0] + cell[1] + cell[2] ) % cell_idx_t(42) );
      }

      // Init scalarField2
      sf = blockIt->getData<ScalarField> ( scalarField2 );
      for( auto cellIt = sf->beginWithGhostLayer(); cellIt != sf->end(); ++cellIt ) // over all x,y,z
      {
         Cell cell ( cellIt.x(), cellIt.y(), cellIt.z() );
         blocks->transformBlockLocalToGlobalCell(cell, *blockIt);
         *cellIt = real_c( ( cell[0] + cell[1] + cell[2] ) % cell_idx_t(42) );
      }

      // Init vector field
      VectorField * vf = blockIt->getData<VectorField> ( vectorField );
      for ( auto cellIt = vf->beginWithGhostLayer(); cellIt != vf->end(); ++cellIt )
      {
         Cell cell ( cellIt.x(), cellIt.y(), cellIt.z() );
         blocks->transformBlockLocalToGlobalCell(cell, *blockIt);
         *cellIt = Vector3<real_t>( real_c(cell[0]), real_c(cell[1]), real_c(cell[2]) );
      }

      // Init Flag field
      FField * ff = blockIt->getData<FField> ( flagField );
      auto flag1 = ff->registerFlag( "AFlag 1" );
      auto flag2 = ff->registerFlag( "BFlag 2" );
      for ( auto cellIt = ff->beginWithGhostLayer(); cellIt != ff->end(); ++cellIt )
      {
         Cell cell ( cellIt.x(), cellIt.y(), cellIt.z() );
         blocks->transformBlockLocalToGlobalCell( cell, *blockIt );
         if ( ( cell[0] + cell[1] + cell[2] ) % 2 )
            addFlag( cellIt, flag1);
         else
            addFlag( cellIt, flag2);
      }

   }

   // Create TimeLoop
   SweepTimeloop timeloop (blocks, nrOfTimeSteps );

   GUI gui (timeloop, blocks, argc, argv);
   lbm::connectToGui<LatticeModel>( gui );
   gui.run();
   //timeloop.singleStep();
   return EXIT_SUCCESS;
}
コード例 #27
0
ファイル: SlidingBrush.cpp プロジェクト: brownman/grall2
//--- NGF events ----------------------------------------------------------------
SlidingBrush::SlidingBrush(Ogre::Vector3 pos, Ogre::Quaternion rot, NGF::ID id, NGF::PropertyList properties, Ogre::String name)
    : NGF::GameObject(pos, rot, id , properties, name),
      mCurrentPlace(0.5),
      mLastPlace(1),
      mForward(false)
{
    addFlag("SlidingBrush");

    //Save the director event.
    NGF_PY_SAVE_EVENT(point);

    //Python init event.
    NGF_PY_CALL_EVENT(init);
    
    //Get properties.
    mEnabled = Ogre::StringConverter::parseBool(mProperties.getValue("enabled", 0, "yes"));
    mSpeed = Ogre::StringConverter::parseReal(mProperties.getValue("speed", 0, "2"));

    //Create the Ogre stuff.
    mEntity = createBrushEntity();
    mNode = GlbVar.ogreSmgr->getRootSceneNode()->createChildSceneNode(mOgreName, pos, rot);
    mNode->attachObject(mEntity);

    //Create the Physics stuff.
    BtOgre::StaticMeshToShapeConverter converter(mEntity);
    mShape = converter.createConvex();
    mShape->setMargin(0); //Bad, but we gotta.

    BtOgre::RigidBodyState *state = new BtOgre::RigidBodyState(mNode);
    mBody = new btRigidBody(0, state, mShape);
    mBody->setCollisionFlags(mBody->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
    mBody->setActivationState(DISABLE_DEACTIVATION);
    initBody();

    //First point is here.
    mPoints.push_back(pos);

    //If we're a simple slider, we just move in one direction till a point and then return.
    Ogre::String distanceStr = mProperties.getValue("distance", 0, "n");

    if(!(distanceStr == "n"))
    {
        Ogre::Real distance = Ogre::StringConverter::parseReal(distanceStr);
        mPoints.push_back(pos + (rot * Ogre::Vector3(0,0,-distance)));
    }
    
    mIgnoreCollisions = Ogre::StringConverter::parseBool(mProperties.getValue("ignoreCollisions", 0, "no"));
    //mIgnoreCollisions = true;

    //Make smaller shape for cast.
    //Get vertices.
    btAlignedObjectArray<btVector3> offsetVerts;
    btVector3 *iter = mShape->getUnscaledPoints(); 
    for (int i = 0; i < mShape->getNumPoints(); ++i, ++iter)
        offsetVerts.push_back(*iter);

    //Push 'em in by 0.1;
    btAlignedObjectArray<btVector3> offsetPlanes;
    btGeometryUtil::getPlaneEquationsFromVertices(offsetVerts, offsetPlanes);
    int sz = offsetPlanes.size();
    for (int i=0 ; i<sz ; ++i) 
        offsetPlanes[i][3] += CAST_SHAPE_SHRINK;
    offsetVerts.clear();
    btGeometryUtil::getVerticesFromPlaneEquations(offsetPlanes, offsetVerts);

    //Fill the shape with the new points.
    mCastShape = new btConvexHullShape();
    for (int i = 0; i < offsetVerts.size() ; ++i) 
        mCastShape->addPoint(offsetVerts[i]);
}