Exemplo n.º 1
0
// Creates a new entity and adds it as the child of the specified one
// Returns the new entity
jobject addEntityToEntity(JNIEnv *env, jobject parentEntity, const char* name)
{
	// Ignore unknown entities
	if (name == NULL)
		return parentEntity;

	// Convert to unicode, using a self-cleaning buffer
	a2w			objName(name);
	wchar_t*	wszName = objName.wget();

	// Find NativeEntity's constructor
	jclass clazz = env->FindClass("com/ixora/rms/agents/db2/DB2RootEntity$NativeEntity");
	jmethodID ctor = env->GetMethodID(clazz, "<init>",
		"(Ljava/lang/String;)V");

	// Create the NativeEntity
	jobject entity = env->NewObject(clazz, ctor, env->NewString((const jchar*)wszName, _tcslen(wszName)));

	if (parentEntity != NULL)
	{
		// Find the add method of the NativeEntity object
		jmethodID addEntity = env->GetMethodID(clazz, "addEntity",
			"(Lcom/ixora/rms/agents/db2/DB2RootEntity$NativeEntity;)V");

		// Use the add method to add the new Entity
		env->CallVoidMethod(parentEntity, addEntity, entity);
	}

	return entity;
}
Exemplo n.º 2
0
ECode CClassInfo::GetConstructorInfoByParamNames(
    /* [in] */ const String& name,
    /* [out] */ IConstructorInfo** constructorInfo)
{
    if (name.IsNull() || !constructorInfo) {
        return E_INVALID_ARGUMENT;
    }

    if (!(mDesc->dwAttribs & ClassAttrib_hasctor)) {
        return E_DOES_NOT_EXIST;
    }

    ECode ec = AcquireConstructorList();
    if (FAILED(ec)) return ec;

    String objName("CreateObjectWith");
    objName += name;

    ec = mCtorList->AcquireObjByName(objName,
            (IInterface **)constructorInfo);
    if (FAILED(ec)) return ec;

    CConstructorInfo* consInfoObj = (CConstructorInfo*)(*constructorInfo);
    consInfoObj->mInstClsId.clsid = mClsId.clsid;
    strcpy(consInfoObj->mInstClsId.pUunm, mClsId.pUunm);

    return NOERROR;
}
Exemplo n.º 3
0
// Creates a new counter and adds it as the child of the specified entity
void addCounterToEntity(JNIEnv *env, jobject parentEntity, const char* name, jobject counterValue)
{
	// Ignore unknown counters
	if (name == NULL)
		return;

	// Convert to unicode, using a self-cleaning buffer
	a2w			objName(name);
	wchar_t*	wszName = objName.wget();

	// Find NativeCounter's constructor
	jclass clazz = env->FindClass("com/ixora/rms/agents/db2/DB2RootEntity$NativeCounter");
	jmethodID ctor = env->GetMethodID(clazz, "<init>",
		"(Ljava/lang/String;Lcom/ixora/rms/data/CounterValue;)V");

	// Create the NativeCounter
	jobject counter = env->NewObject(clazz, ctor,
		env->NewString((const jchar*)wszName, _tcslen(wszName)), counterValue);

	// Find the add method of the NativeEntity object
	clazz = env->FindClass("com/ixora/rms/agents/db2/DB2RootEntity$NativeEntity");
	jmethodID addCounter = env->GetMethodID(clazz, "addCounter",
		"(Lcom/ixora/rms/agents/db2/DB2RootEntity$NativeCounter;)V");

	// Use the add method to add the new counter
	env->CallVoidMethod(parentEntity, addCounter, counter);
}
Exemplo n.º 4
0
//===============================================================
// Name:		G_PurchaseSkillCmd
// Class:		None
//
// Description: Purchases a skill for the current player.  This
//				goes into the gameplay database and looks for a
//				CurrentPlayer object who has a skillPoints property.
//
//				If its found, we attempt to increment the value
//				of the skill specified in the command's first argument.
//				We also decrement by one the number of available skillPoints.
// 
// Parameters:	gentity_t -- the entity issuing the command. Not used.
//
// Returns:		qboolean -- true if the command was executed.
// 
//===============================================================
qboolean G_PurchaseSkillCmd( const gentity_t *ent )
{
	str propname ;

	if ( gi.argc() < 1 ) return qfalse ;

	propname = gi.argv( 1 );

	GameplayManager *gpm = GameplayManager::getTheGameplayManager();
	if ( !gpm ) return false ;

	float skillPoints = gpm->getFloatValue( "CurrentPlayer", "SkillPoints" );
	if ( skillPoints > 0.0f )
	{
		str objName("CurrentPlayer.");
		objName += propname ;
		float skillValue = gpm->getFloatValue( objName, "value" );
		if ( skillValue < gpm->getFloatValue( objName, "max" ) )
		{
			gpm->setFloatValue( objName, "value", skillValue + 1.0f );
			gpm->setFloatValue( "CurrentPlayer", "SkillPoints", skillPoints - 1.0f );

			if ( ent->entity->isSubclassOf( Player ) )
			{
				Player *player = (Player*)ent->entity;
				player->skillChanged( objName );
			}
		}
	}

	return qtrue ;
}
Exemplo n.º 5
0
void CqImageBuffer::RepostSurface(const CqBucket& oldBucket,
                                  const boost::shared_ptr<CqSurface>& surface)
{
	const CqBound rasterBound = surface->GetCachedRasterBound();

	bool wasPosted = false;
	// Surface is behind everying in this bucket but it may be visible in other
	// buckets it overlaps.
	//
	// First look in bucket to the right
	TqInt nextBucketX = oldBucket.getCol() + 1;
	TqInt nextBucketY = oldBucket.getRow();
	TqInt xpos = oldBucket.getXPosition() + oldBucket.getXSize();
	if ( nextBucketX < m_bucketRegion.xMax() && rasterBound.vecMax().x() >= xpos )
	{
		Bucket( nextBucketX, nextBucketY ).AddGPrim( surface );
		wasPosted = true;
	}
	else
	{
		// next row
		++nextBucketY;
		// find bucket containing left side of bound
		nextBucketX = max<TqInt>(m_bucketRegion.xMin(),
				lfloor(rasterBound.vecMin().x())/m_optCache.xBucketSize);
		TqInt ypos = oldBucket.getYPosition() + oldBucket.getYSize();

		if ( ( nextBucketX < m_bucketRegion.xMax() ) &&
			( nextBucketY  < m_bucketRegion.yMax() ) &&
			( rasterBound.vecMax().y() >= ypos ) )
		{
			Bucket( nextBucketX, nextBucketY ).AddGPrim( surface );
			wasPosted = true;
		}
	}

#ifdef DEBUG
	// Print info about reposting.  This is protected by DEBUG so that scenes
	// with huge amounts of occlusion won't silently be causing *heaps* of
	// logging traffic.
	CqString objName("unnamed");
	if(const CqString* name = surface->pAttributes()
			->GetStringAttribute("identifier", "name"))
		objName = name[0];
	if(wasPosted)
	{
		Aqsis::log() << info << "GPrim: \"" << objName
			<< "\" occluded in bucket: "
			<< oldBucket.getCol() << ", " << oldBucket.getRow()
			<< " shifted into bucket: "
			<< nextBucketX << ", " << nextBucketY << "\n";
	}
	else
	{
		Aqsis::log() << info
			<< "GPrim: \"" << objName << "\" occlusion culled" << std::endl;
	}
#endif
}
Exemplo n.º 6
0
const NAString QualifiedName::getQualifiedNameAsAnsiNTFilenameString() const
{
  // Preallocate a result buffer that'll be big enough most of the time
  // (so += won't reallocate+copy most of the time).
  NAString result((NASize_T)40, CmpCommon::statementHeap());

  NAString catName(CmpCommon::statementHeap());
  NAString schName(CmpCommon::statementHeap());
  NAString objName(CmpCommon::statementHeap());

  formatAsAnsiIdentifier = TRUE;	// put quotes on delimited identifiers

  if ( NOT getCatalogName().isNull() ) {
    catName = FORMAT(getCatalogName());
    makeSafeFilenamePart(catName, "SQLMX_DEFAULT_CATALOG_");
  }
  if ( NOT getSchemaName().isNull() ) {
    schName = FORMAT(getSchemaName());
    makeSafeFilenamePart(schName, "SQLMX_DEFAULT_SCHEMA_");
  }
  if ( NOT getObjectName().isNull() ) {
    objName = FORMAT(getObjectName());
  }
  makeSafeFilenamePart(objName, "SQLMX_DEFAULT_FILE_");

  formatAsAnsiIdentifier = FALSE;	// reset to initial value

  size_t totlen = catName.length() + schName.length() + objName.length() + 2;

  if ( totlen > 255 ) {					// need to truncate
    // +1 so round off doesn't give us less than what we need to chop
    size_t chopLen = totlen - 255 + 1;  
             
    if ( catName.length() - chopLen/2 <= 0 )		// cat too short
      schName.remove( schName.length() - chopLen );
    else if ( schName.length() - chopLen/2 <= 0 )	// sch too short
      catName.remove( catName.length() - chopLen );
    else {						// chop from both
      // remember position starts at 0 and length is 1 more
      chopLen /= 2;
      catName.remove( catName.length() - chopLen - 1 );
      schName.remove( schName.length() - chopLen - 1 );
    }
  }

  if (NOT catName.isNull()) {
    result = catName;
    result += ".";
  }
  if (NOT schName.isNull()) {
    result += schName;
    result += ".";
  }
  result += objName;

  return result;
}
/**
Read security policies from security policy table.

The method does not guarantee that either the security policies will be read from the 
security table and stored in aSecurityPolicy parameter or aSecurityPolicy argument 
stays unchanged in a case of failure.

@param aSecurityPolicyCon Security policies container which needs to be initializeed with 
						  the database security policies.

@leave KErrNoMemory, an out of memory condition has occurred;
	   KErrGeneral, missing or invalid data in the system tables;
                  Note that the function may also leave with some other database specific 
                  errors categorised as ESqlDbError, and other system-wide error codes.
@panic SqlDb 2 In _DEBUG mode if iDbHandle is NULL (uninitialized TSqlDbSysSettings object).
*/
void TSqlDbSysSettings::LoadSecurityPolicyL(CSqlSecurityPolicy& aSecurityPolicyCon)
	{
	__ASSERT_DEBUG(iDbHandle != NULL, __SQLPANIC(ESqlPanicInvalidObj));
	//Even if the version of the system settings is bigger than the current one (KSqlSystemVersion constant),
	//I think that all future modifications of the system tables shall not affect the already existing
	//fields. So it is correct to think that all information available in version 1 should be available 
	//(and accessible) in all future versions of the system settings.
	//Note: no attempt shall be made here to modify the system tables structure! There may be more than one 
	//      connection to the database being processed!
	//
	//Prepare statement handle
	sqlite3_stmt* stmtHandle = ::StmtPrepare8L(iDbHandle, KGetSecuritySql());
	CleanupStack::PushL(TCleanupItem(&FinalizeStatementHandle, stmtHandle));
	//Read the security policies
	TBool defaultPolicySet = EFalse;
	TInt dbPolicySetFlag = 0;
	TInt err;
	while((err = ::StmtNext(stmtHandle)) == KSqlAtRow)
		{
		TInt objType = KDefaultObjType - 1;
		TPtrC objName(KNullDesC);
		TInt policyType = RSqlSecurityPolicy::ESchemaPolicy - 1;
		TSecurityPolicy policy = ReadCurrSecurityPolicyL(stmtHandle, objType, objName, policyType);
		switch(objType)
			{
			case KDefaultObjType:
				if(defaultPolicySet)
					{
					__SQLLEAVE(KErrGeneral);//two "default policy" records in the table
					}
				StoreDefaultSecurityPolicy(aSecurityPolicyCon, policy, dbPolicySetFlag);
				defaultPolicySet = ETrue;
				break;
			case KDbObjType:
				StoreDbSecurityPolicyL(aSecurityPolicyCon, policyType, policy, dbPolicySetFlag);
				break;
			case RSqlSecurityPolicy::ETable:
				StoreDbObjSecurityPolicyL(aSecurityPolicyCon, objType, objName, policyType, policy);
				break;
			default:
				__SQLLEAVE(KErrGeneral);
				break;
			}//end of "switch(aObjType)"
		}
	CleanupStack::PopAndDestroy();//cleanupItem (statement handle)
	__SQLLEAVE_IF_ERROR(err);
	if(!defaultPolicySet)
		{
		__SQLLEAVE(KErrGeneral);//no default policy
		}
	}
Exemplo n.º 8
0
void WebListener::executeFunction(const he::String& object,
                                    const he::String& method,
                                    const Awesomium::JSArray& args)
{
    // global js object for global functions
    he::String objName("window");
    Awesomium::WebString aweMethod = Awesomium::WSLit(method.c_str());

    if (object != "window" && object != "")
    {
        objName = object;

        // check if jsobject already exists
        auto it(std::find_if(m_Objects.cbegin(), m_Objects.cend(), [&objName](JSObject* obj)
        {
            return obj->getObjectName() == objName;
        }));
        
        bool objectExists(it != m_Objects.cend());

        // create new js object if it doesn't already exists
        if (objectExists == false)
        {
            Awesomium::JSValue val = m_WebView->CreateGlobalJavascriptObject(
                Awesomium::WSLit(objName.c_str()));

            Awesomium::JSObject& obj = val.ToObject();

            JSObject* jsObject(HENew(JSObject)(obj, objName));

            m_Objects.add(jsObject);

            jsObject->executeFunction(aweMethod, args);
        }
        else
        {
            (*it)->executeFunction(aweMethod, args);
        };
    }
    else
    {
        Awesomium::JSValue window(
            m_WebView->ExecuteJavascriptWithResult(
            Awesomium::WSLit("window"), Awesomium::WSLit("")));

        Awesomium::JSObject& obj = window.ToObject();

        obj.Invoke(aweMethod, args);
    }
}
  void SpacesSubtabGridView::spaceNameFilterChanged()
  {
    m_objectsFilteredBySpaceName.clear();

    if (m_spaceNameFilter->text().isEmpty()) {
      // nothing to filter
    }
    else {
      for (auto obj : this->m_gridController->m_modelObjects) {
        QString objName(obj.name().get().c_str());
        if (!objName.contains(m_spaceNameFilter->text(), Qt::CaseInsensitive)) {
          m_objectsFilteredBySpaceName.insert(obj);
        }
      }
    }

    filterChanged();
  }
Exemplo n.º 10
0
  void FacilityShadingGridView::nameFilterChanged()
  {
    m_objectsFilteredByName.clear();

    if (m_nameFilter->text().isEmpty()) {
      // nothing to filter
    }
    else {
      for (auto obj : this->m_gridController->getObjectSelector()->m_selectorObjects) {
        QString objName(obj.name().get().c_str());
        if (!objName.contains(m_nameFilter->text(), Qt::CaseInsensitive)) {
          m_objectsFilteredByName.insert(obj);
        }
      }
    }

    filterChanged();
  }
Exemplo n.º 11
0
const gchar *
getNameCB(AtkObject *aAtkObj)
{
    nsAccessibleWrap *accWrap = GetAccessibleWrap(aAtkObj);
    if (!accWrap) {
        return nsnull;
    }

    /* nsIAccessible is responsible for the non-NULL name */
    nsAutoString uniName;
    nsresult rv = accWrap->GetName(uniName);
    NS_ENSURE_SUCCESS(rv, nsnull);

    NS_ConvertUTF8toUTF16 objName(aAtkObj->name);
    if (!uniName.Equals(objName)) {
        atk_object_set_name(aAtkObj,
                            NS_ConvertUTF16toUTF8(uniName).get());
    }
    return aAtkObj->name;
}
Exemplo n.º 12
0
static bool
FindNamedObject(const ComparatorFnT& aComparator)
{
  // We want to enumerate every named kernel object in our session. We do this
  // by opening a directory object using a path constructed using the session
  // id under which our process resides.
  DWORD sessionId;
  if (!::ProcessIdToSessionId(::GetCurrentProcessId(), &sessionId)) {
    return false;
  }

  nsAutoString path;
  path.AppendPrintf("\\Sessions\\%u\\BaseNamedObjects", sessionId);

  UNICODE_STRING baseNamedObjectsName;
  ::RtlInitUnicodeString(&baseNamedObjectsName, path.get());

  OBJECT_ATTRIBUTES attributes;
  InitializeObjectAttributes(&attributes, &baseNamedObjectsName, 0,
                             nullptr, nullptr);

  HANDLE rawBaseNamedObjects;
  NTSTATUS ntStatus = ::NtOpenDirectoryObject(&rawBaseNamedObjects,
                                              DIRECTORY_QUERY | DIRECTORY_TRAVERSE,
                                              &attributes);
  if (!NT_SUCCESS(ntStatus)) {
    return false;
  }

  nsAutoHandle baseNamedObjects(rawBaseNamedObjects);

  ULONG context = 0, returnedLen;

  ULONG objDirInfoBufLen = 1024 * sizeof(OBJECT_DIRECTORY_INFORMATION);
  ObjDirInfoPtr objDirInfo(
    reinterpret_cast<OBJECT_DIRECTORY_INFORMATION*>(new char[objDirInfoBufLen]));

  // Now query that directory object for every named object that it contains.

  BOOL firstCall = TRUE;

  do {
    ntStatus = ::NtQueryDirectoryObject(baseNamedObjects, objDirInfo.get(),
                                        objDirInfoBufLen, FALSE, firstCall,
                                        &context, &returnedLen);
#if defined(HAVE_64BIT_BUILD)
    if (!NT_SUCCESS(ntStatus)) {
      return false;
    }
#else
    if (ntStatus == STATUS_BUFFER_TOO_SMALL) {
      // This case only occurs on 32-bit builds running atop WOW64.
      // (See https://bugzilla.mozilla.org/show_bug.cgi?id=1423999#c3)
      objDirInfo.reset(reinterpret_cast<OBJECT_DIRECTORY_INFORMATION*>(new char[returnedLen]));
      objDirInfoBufLen = returnedLen;
      continue;
    } else if (!NT_SUCCESS(ntStatus)) {
      return false;
    }
#endif

    // NtQueryDirectoryObject gave us an array of OBJECT_DIRECTORY_INFORMATION
    // structures whose final entry is zeroed out.
    OBJECT_DIRECTORY_INFORMATION* curDir = objDirInfo.get();
    while (curDir->mName.Length && curDir->mTypeName.Length) {
      // We use nsDependentSubstring here because UNICODE_STRINGs are not
      // guaranteed to be null-terminated.
      nsDependentSubstring objName(curDir->mName.Buffer,
                                   curDir->mName.Length / sizeof(wchar_t));
      nsDependentSubstring typeName(curDir->mTypeName.Buffer,
                                    curDir->mTypeName.Length / sizeof(wchar_t));

      if (!aComparator(objName, typeName)) {
        return true;
      }

      ++curDir;
    }

    firstCall = FALSE;
  } while (ntStatus == STATUS_MORE_ENTRIES);

  return false;
}
Exemplo n.º 13
0
// ### we may end up with a different search order than QtScript by not
// folding this code into the fallbackMethod above, but Fields propagate out
// of the binding code
Field* QtClass::fieldNamed(const Identifier& identifier, Instance* instance) const
{
    // Check static properties first
    QtInstance* qtinst = static_cast<QtInstance*>(instance);

    QObject* obj = qtinst->getObject();
    UString ustring = identifier.ustring();
    QString objName(QString::fromUtf16((const ushort*)ustring.rep()->data(),ustring.size()));
    QByteArray ba = objName.toAscii();

    // First check for a cached field
    QtField* f = qtinst->m_fields.value(objName);

    if (obj) {
        if (f) {
            // We only cache real metaproperties, but we do store the
            // other types so we can delete them later
            if (f->fieldType() == QtField::MetaProperty)
                return f;
            else if (f->fieldType() == QtField::DynamicProperty) {
                if (obj->dynamicPropertyNames().indexOf(ba) >= 0)
                    return f;
                else {
                    // Dynamic property that disappeared
                    qtinst->m_fields.remove(objName);
                    delete f;
                }
            } else {
                QList<QObject*> children = obj->children();
                for (int index = 0; index < children.count(); ++index) {
                    QObject *child = children.at(index);
                    if (child->objectName() == objName)
                        return f;
                }

                // Didn't find it, delete it from the cache
                qtinst->m_fields.remove(objName);
                delete f;
            }
        }

        int index = m_metaObject->indexOfProperty(identifier.ascii());
        if (index >= 0) {
            QMetaProperty prop = m_metaObject->property(index);

            if (prop.isScriptable(obj)) {
                f = new QtField(prop);
                qtinst->m_fields.insert(objName, f);
                return f;
            }
        }

        // Dynamic properties
        index = obj->dynamicPropertyNames().indexOf(ba);
        if (index >= 0) {
            f = new QtField(ba);
            qtinst->m_fields.insert(objName, f);
            return f;
        }

        // Child objects

        QList<QObject*> children = obj->children();
        for (index = 0; index < children.count(); ++index) {
            QObject *child = children.at(index);
            if (child->objectName() == objName) {
                f = new QtField(child);
                qtinst->m_fields.insert(objName, f);
                return f;
            }
        }

        // Nothing named this
        return 0;
    } else {
        QByteArray ba(identifier.ascii());
        // For compatibility with qtscript, cached methods don't cause
        // errors until they are accessed, so don't blindly create an error
        // here.
        if (qtinst->m_methods.contains(ba))
            return 0;

        // deleted qobject, but can't throw an error from here (no exec)
        // create a fake QtField that will throw upon access
        if (!f) {
            f = new QtField(ba);
            qtinst->m_fields.insert(objName, f);
        }
        return f;
    }
}
// *****************************************************************************
// *                                                                           *
// * Function: CmpSeabaseDDL::giveSeabaseSchema                                *
// *                                                                           *
// *    Implements the GIVE SCHEMA command.                                    *
// *                                                                           *
// *****************************************************************************
// *                                                                           *
// *  Parameters:                                                              *
// *                                                                           *
// *  <giveSchemaNode>                StmtDDLGiveSchema *             In       *
// *    is a pointer to a create schema parser node.                           *
// *                                                                           *
// *  <currentCatalogName>            NAString &                      In       *
// *    is the name of the current catalog.                                    *
// *                                                                           *
// *****************************************************************************
void CmpSeabaseDDL::giveSeabaseSchema(
   StmtDDLGiveSchema * giveSchemaNode,
   NAString          & currentCatalogName)
   
{

ComDropBehavior dropBehavior = giveSchemaNode->getDropBehavior(); 
NAString catalogName = giveSchemaNode->getCatalogName();
NAString schemaName = giveSchemaNode->getSchemaName();

   if (catalogName.isNull())
      catalogName = currentCatalogName;  

ExeCliInterface cliInterface(STMTHEAP, NULL, NULL,
CmpCommon::context()->sqlSession()->getParentQid());
Int32 objectOwnerID = 0;
Int32 schemaOwnerID = 0;
ComObjectType objectType;

Int64 schemaUID = getObjectTypeandOwner(&cliInterface,catalogName.data(),
                                        schemaName.data(),SEABASE_SCHEMA_OBJECTNAME,
                                        objectType,schemaOwnerID);
                                       
   if (schemaUID == -1)
   {
      // A Trafodion schema does not exist if the schema object row is not
      // present: CATALOG-NAME.SCHEMA-NAME.__SCHEMA__.
      *CmpCommon::diags() << DgSqlCode(-CAT_SCHEMA_DOES_NOT_EXIST_ERROR)
                          << DgSchemaName(schemaName.data());
      return;
   }
   
// *****************************************************************************
// *                                                                           *
// *    A schema owner can give their own schema to another authID, but they   *
// * cannot give the objects in a shared schema to another authID.  Only       *
// * DB__ROOT or a user with the ALTER_SCHEMA privilege can change the owners  *
// * of objects in a shared schema.  So if the schema is private, or if only   *
// * the schema is being given, we do standard authentication checking.  But   *
// * if giving all the objects in a shared schema, we change the check ID to   *
// * the default user to force the ALTER_SCHEMA privilege check.               *
// *                                                                           *
// *****************************************************************************

int32_t checkID = schemaOwnerID;

   if (objectType == COM_SHARED_SCHEMA_OBJECT && 
       dropBehavior == COM_CASCADE_DROP_BEHAVIOR)
      checkID = NA_UserIdDefault; 

   if (!isDDLOperationAuthorized(SQLOperation::ALTER_SCHEMA,checkID,checkID))
   {
      *CmpCommon::diags() << DgSqlCode(-CAT_NOT_AUTHORIZED);
      return;
   }
 
ComObjectName objName(catalogName,schemaName,NAString("dummy"),COM_TABLE_NAME,TRUE);

   if (isSeabaseReservedSchema(objName) &&
       !Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL))
   {
      *CmpCommon::diags() << DgSqlCode(-CAT_USER_CANNOT_DROP_SMD_SCHEMA)
                          << DgSchemaName(schemaName.data());
      return;
   }
   
bool isVolatile = (memcmp(schemaName.data(),"VOLATILE_SCHEMA",strlen("VOLATILE_SCHEMA")) == 0);

// Can't give a schema whose name begins with VOLATILE_SCHEMA. 
   if (isVolatile)
   {
      *CmpCommon::diags() << DgSqlCode(-CAT_RESERVED_METADATA_SCHEMA_NAME)
                          << DgTableName(schemaName);
      return;
   }
   
int32_t newOwnerID = -1;

   if (ComUser::getAuthIDFromAuthName(giveSchemaNode->getAuthID().data(),
                                      newOwnerID) != 0)
   {
      *CmpCommon::diags() << DgSqlCode(-CAT_AUTHID_DOES_NOT_EXIST_ERROR)
                          << DgString0(giveSchemaNode->getAuthID().data());
      return;
   }

// *****************************************************************************
// *                                                                           *
// *   Drop behavior is only relevant for shared schemas.  For shared schemas, *
// * ownership of the schema OR the schema and all its objects may be given to *
// * another authorization ID.  For private schemas, all objects are owned by  *
// * the schema owner, so the drop behavior is always CASCADE.                 *
// *                                                                           *
// * NOTE: The syntax for drop behavior always defaults to RESTRICT; for       *
// *       private schemas this is simply ignored, as opposed to requiring     *
// *       users to always specify CASCASE.                                    *
// *                                                                           *
// *****************************************************************************

Lng32 cliRC = 0;
char buf[4000];
   
   if (objectType == COM_SHARED_SCHEMA_OBJECT && 
       dropBehavior == COM_RESTRICT_DROP_BEHAVIOR)
   {
      str_sprintf(buf,"UPDATE %s.\"%s\".%s "
                      "SET object_owner = %d "
                      "WHERE object_UID = %Ld",
                  getSystemCatalog(),SEABASE_MD_SCHEMA,SEABASE_OBJECTS,
                  newOwnerID,schemaUID);
      cliRC = cliInterface.executeImmediate(buf);
      if (cliRC < 0)
         cliInterface.retrieveSQLDiagnostics(CmpCommon::diags());
                      
      return;
   }
//
// At this point, we are giving all objects in the schema (as well as the 
// schema itself) to the new authorization ID.  If authentication is enabled,
// update the privileges first.
//
   if (isAuthorizationEnabled())
   {
      int32_t rc = transferObjectPrivs(getSystemCatalog(),catalogName.data(),
                                       schemaName.data(),newOwnerID,
                                       giveSchemaNode->getAuthID().data());
      if (rc != 0)
      {
         if (CmpCommon::diags()->getNumber(DgSqlCode::ERROR_) == 0)
         {
          //TODO: add error
         
         }
         return;
      }
   }
   
// Now update the object owner for all objects in the schema.
      
   str_sprintf(buf,"UPDATE %s.\"%s\".%s "
                   "SET object_owner = %d "
                   "WHERE catalog_name = '%s' AND schema_name = '%s'",
               getSystemCatalog(),SEABASE_MD_SCHEMA,SEABASE_OBJECTS,
               newOwnerID,catalogName.data(),schemaName.data());
   cliRC = cliInterface.executeImmediate(buf);
   if (cliRC < 0)
   {
      cliInterface.retrieveSQLDiagnostics(CmpCommon::diags());
      return;
   }             

// Verify all objects in the schema have been given to the new owner.   
   str_sprintf(buf,"SELECT COUNT(*) "
                   "FROM %s.\"%s\".%s "
                   "WHERE catalog_name = '%s' AND schema_name = '%s' AND "
                   "object_name <> '"SEABASE_SCHEMA_OBJECTNAME"' AND "
                   "object_owner <> %d " 
                   "FOR READ COMMITTED ACCESS",
               getSystemCatalog(),SEABASE_MD_SCHEMA,SEABASE_OBJECTS,
               catalogName.data(),schemaName.data(),newOwnerID);
               
int32_t length = 0;
int32_t rowCount = 0;

   cliRC = cliInterface.executeImmediate(buf,(char*)&rowCount,&length,NULL);
  
   if (cliRC < 0)
   {
      cliInterface.retrieveSQLDiagnostics(CmpCommon::diags());
      return;
   }
   
   if (rowCount > 0)
   {
      SEABASEDDL_INTERNAL_ERROR("Not all objects in schema were given");
      return;
   }
    
}
// *****************************************************************************
// *                                                                           *
// * Function: CmpSeabaseDDL::dropSeabaseSchema                                *
// *                                                                           *
// *    Implements the DROP SCHEMA command.                                    *
// *                                                                           *
// *****************************************************************************
// *                                                                           *
// *  Parameters:                                                              *
// *                                                                           *
// *  <dropSchemaNode>                StmtDDLDropSchema *             In       *
// *    is a pointer to a create schema parser node.                           *
// *                                                                           *
// *****************************************************************************
void CmpSeabaseDDL::dropSeabaseSchema(StmtDDLDropSchema * dropSchemaNode)
   
{

Lng32 cliRC = 0;

ComSchemaName schemaName(dropSchemaNode->getSchemaName());
NAString catName = schemaName.getCatalogNamePartAsAnsiString();
ComAnsiNamePart schNameAsComAnsi = schemaName.getSchemaNamePart();
NAString schName = schNameAsComAnsi.getInternalName();

ExeCliInterface cliInterface(STMTHEAP, NULL, NULL, 
CmpCommon::context()->sqlSession()->getParentQid());
Int32 objectOwnerID = 0;
Int32 schemaOwnerID = 0;
ComObjectType objectType;

   Int64 schemaUID = getObjectTypeandOwner(&cliInterface,catName.data(),schName.data(),
                             SEABASE_SCHEMA_OBJECTNAME,objectType,schemaOwnerID);
   
   // if schemaUID == -1, then either the schema does not exist or an unexpected error occurred
   if (schemaUID == -1)
   {
      // If an error occurred, return
      if (CmpCommon::diags()->getNumber(DgSqlCode::ERROR_) > 0)
        return;
 
      // schema does not exist and IF EXISTS specified, then ignore and continue
      if (dropSchemaNode->dropIfExists())
        return;

      // A Trafodion schema does not exist if the schema object row is not
      // present: CATALOG-NAME.SCHEMA-NAME.__SCHEMA__.
      *CmpCommon::diags() << DgSqlCode(-CAT_SCHEMA_DOES_NOT_EXIST_ERROR)
                          << DgSchemaName(schemaName.getExternalName().data());
      return;
   }

   if (!isDDLOperationAuthorized(SQLOperation::DROP_SCHEMA,
                                 schemaOwnerID,schemaOwnerID))
   {
      *CmpCommon::diags() << DgSqlCode(-CAT_NOT_AUTHORIZED);
      return;
   }
 
ComObjectName objName(catName,schName,NAString("dummy"),COM_TABLE_NAME,TRUE);

   if ((isSeabaseReservedSchema(objName) ||
        (schName == SEABASE_SYSTEM_SCHEMA)) &&
       !Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL))
   {
      *CmpCommon::diags() << DgSqlCode(-CAT_USER_CANNOT_DROP_SMD_SCHEMA)
                          << DgSchemaName(schemaName.getExternalName().data());
      return;
   }
   
bool isVolatile = (memcmp(schName.data(),"VOLATILE_SCHEMA",strlen("VOLATILE_SCHEMA")) == 0);

// Can't drop a schema whose name begins with VOLATILE_SCHEMA unless the 
// keyword VOLATILE was specified in the DROP SCHEMA command. 
   if (isVolatile && !dropSchemaNode->isVolatile())
   {
      *CmpCommon::diags() << DgSqlCode(-CAT_RESERVED_METADATA_SCHEMA_NAME)
                          << DgTableName(schName);
      return;
   }

// Get a list of all objects in the schema, excluding the schema object itself.
char query[4000];

   str_sprintf(query,"SELECT TRIM(object_name), TRIM(object_type) "
                     "FROM %s.\"%s\".%s "
                     "WHERE catalog_name = '%s' AND schema_name = '%s' AND "
                     "object_name <> '"SEABASE_SCHEMA_OBJECTNAME"'" 
                     "FOR READ COMMITTED ACCESS",
               getSystemCatalog(),SEABASE_MD_SCHEMA,SEABASE_OBJECTS,
               (char*)catName.data(),(char*)schName.data());
  
Queue * objectsQueue = NULL;

   cliRC = cliInterface.fetchAllRows(objectsQueue, query, 0, FALSE, FALSE, TRUE);
   if (cliRC < 0)
   {
      cliInterface.retrieveSQLDiagnostics(CmpCommon::diags());
      return;
   }

   objectsQueue->position();
   if ((dropSchemaNode->getDropBehavior() == COM_RESTRICT_DROP_BEHAVIOR) &&
       (objectsQueue->numEntries() > 0))
   {
      OutputInfo * oi = (OutputInfo*)objectsQueue->getCurr(); 
      
      *CmpCommon::diags() << DgSqlCode(-CAT_SCHEMA_IS_NOT_EMPTY)
                          << DgTableName(oi->get(0));
      return;
   }

bool someObjectsCouldNotBeDropped = false;

// Drop libraries, procedures (SPJs), UDFs (functions), and views 
   objectsQueue->position();
   for (int idx = 0; idx < objectsQueue->numEntries(); idx++)
   {
      OutputInfo * vi = (OutputInfo*)objectsQueue->getNext(); 

      char * objName = vi->get(0);
      NAString objectTypeLit = vi->get(1);
      ComObjectType objectType = PrivMgr::ObjectLitToEnum(objectTypeLit.data());
      char buf[1000];
      NAString objectTypeString;
      NAString cascade = " ";
      
      switch (objectType)
      {
         // These object types are handled later and can be ignored for now.
         case COM_BASE_TABLE_OBJECT:
         case COM_INDEX_OBJECT:
         case COM_CHECK_CONSTRAINT_OBJECT:
         case COM_NOT_NULL_CONSTRAINT_OBJECT:
         case COM_PRIMARY_KEY_CONSTRAINT_OBJECT:
         case COM_REFERENTIAL_CONSTRAINT_OBJECT:
         case COM_SEQUENCE_GENERATOR_OBJECT:
         case COM_UNIQUE_CONSTRAINT_OBJECT:
         {
            continue;
         }
         case COM_LIBRARY_OBJECT:
         {
            objectTypeString = "LIBRARY";
            cascade = "CASCADE";
            break;
         }
         case COM_STORED_PROCEDURE_OBJECT:
         {
            objectTypeString = "PROCEDURE";
            break;
         }
         case COM_USER_DEFINED_ROUTINE_OBJECT:
         {
            objectTypeString = "FUNCTION";
            cascade = "CASCADE";
            break;
         }
         case COM_VIEW_OBJECT:
         {
            objectTypeString = "VIEW";
            cascade = "CASCADE";
            break;
         }
         // These object types should not be seen.
         case COM_MV_OBJECT: 
         case COM_MVRG_OBJECT:    
         case COM_TRIGGER_OBJECT:
         case COM_LOB_TABLE_OBJECT:
         case COM_TRIGGER_TABLE_OBJECT:
         case COM_SYNONYM_OBJECT:
         case COM_PRIVATE_SCHEMA_OBJECT:
         case COM_SHARED_SCHEMA_OBJECT:
         case COM_EXCEPTION_TABLE_OBJECT:
         case COM_LOCK_OBJECT:
         case COM_MODULE_OBJECT:
         default:
            SEABASEDDL_INTERNAL_ERROR("Unrecognized object type in schema");
            return;
      }
         
      str_sprintf(buf, "drop %s \"%s\".\"%s\".\"%s\" %s",
                  objectTypeString.data(),(char*)catName.data(),(char*)schName.data(), 
                  objName,cascade.data());
         
      cliRC = cliInterface.executeImmediate(buf);
      if (cliRC < 0 && cliRC != -CAT_OBJECT_DOES_NOT_EXIST_IN_TRAFODION)
         someObjectsCouldNotBeDropped = true;
   } 

// Drop all tables in the schema.  This will also drop any associated constraints. 
// Drop of histogram tables is deferred.
bool histExists = false;

   objectsQueue->position();
   for (int idx = 0; idx < objectsQueue->numEntries(); idx++)
   {
      OutputInfo * vi = (OutputInfo*)objectsQueue->getNext(); 

      NAString objName = vi->get(0);
      NAString objType = vi->get(1);

      // drop user objects first
      if (objType == COM_BASE_TABLE_OBJECT_LIT)
      {
         if (!(objName == HBASE_HIST_NAME || objName == HBASE_HISTINT_NAME))
         {
            if (dropOneTable(cliInterface,(char*)catName.data(), 
                             (char*)schName.data(),(char*)objName.data(),
                             isVolatile))
               someObjectsCouldNotBeDropped = true;
         }
         else
            histExists = true;
      } 
   } 

// Drop any remaining indexes.

   str_sprintf(query,"SELECT TRIM(object_name), TRIM(object_type) "
                     "FROM %s.\"%s\".%s "
                     "WHERE catalog_name = '%s' AND "
                     "      schema_name = '%s' AND "
                     "      object_type = '%s' "
                     "FOR READ COMMITTED ACCESS ",
               getSystemCatalog(),SEABASE_MD_SCHEMA,SEABASE_OBJECTS,
               (char*)catName.data(),(char*)schName.data(), 
               COM_INDEX_OBJECT_LIT);
   
   cliRC = cliInterface.fetchAllRows(objectsQueue,query,0,FALSE,FALSE,TRUE);
   if (cliRC < 0)
   {
      cliInterface.retrieveSQLDiagnostics(CmpCommon::diags());
      return;
   }

   objectsQueue->position();
   for (int idx = 0; idx < objectsQueue->numEntries(); idx++)
   {
      OutputInfo * vi = (OutputInfo*)objectsQueue->getNext(); 

      char * objName = vi->get(0);
      NAString objType = vi->get(1);
    
      if (objType == COM_INDEX_OBJECT_LIT)
      {
         char buf [1000];

         str_sprintf(buf, "DROP INDEX \"%s\".\"%s\".\"%s\" CASCADE",
                     (char*)catName.data(), (char*)schName.data(), objName);
         cliRC = cliInterface.executeImmediate(buf);

         if (cliRC < 0 && cliRC != -CAT_OBJECT_DOES_NOT_EXIST_IN_TRAFODION)
            someObjectsCouldNotBeDropped = true;
      }  
   }  

// Drop any remaining sequences.

   str_sprintf(query,"SELECT TRIM(object_name), TRIM(object_type) "
                     "FROM %s.\"%s\".%s "
                     "WHERE catalog_name = '%s' AND "
                     "      schema_name = '%s' AND "
                     "      object_type = '%s' "
                     "FOR READ COMMITTED ACCESS ",
               getSystemCatalog(),SEABASE_MD_SCHEMA,SEABASE_OBJECTS,
               (char*)catName.data(),(char*)schName.data(), 
               COM_SEQUENCE_GENERATOR_OBJECT_LIT);
   
   cliRC = cliInterface.fetchAllRows(objectsQueue,query,0,FALSE,FALSE,TRUE);
   if (cliRC < 0)
   {
      cliInterface.retrieveSQLDiagnostics(CmpCommon::diags());
      return;
   }

   objectsQueue->position();
   for (int idx = 0; idx < objectsQueue->numEntries(); idx++)
   {
      OutputInfo * vi = (OutputInfo*)objectsQueue->getNext(); 

      char * objName = vi->get(0);
      NAString objType = vi->get(1);
    
      if (objType == COM_SEQUENCE_GENERATOR_OBJECT_LIT)
      {
         char buf [1000];

         str_sprintf(buf, "DROP SEQUENCE \"%s\".\"%s\".\"%s\"",
                     (char*)catName.data(), (char*)schName.data(), objName);
         cliRC = cliInterface.executeImmediate(buf);

         if (cliRC < 0 && cliRC != -CAT_OBJECT_DOES_NOT_EXIST_IN_TRAFODION)
            someObjectsCouldNotBeDropped = true;
      }  
   }  

// For volatile schemas, sometimes only the objects get dropped.    
// If the dropObjectsOnly flag is set, just exit now, we are done.
   if (dropSchemaNode->dropObjectsOnly())
      return;

// Now drop any histogram objects
   if (histExists)
   {
      if (dropOneTable(cliInterface,(char*)catName.data(),(char*)schName.data(), 
                      (char*)HBASE_HISTINT_NAME,false))
         someObjectsCouldNotBeDropped = true;
      
      if (dropOneTable(cliInterface,(char*)catName.data(),(char*)schName.data(), 
                       (char*)HBASE_HIST_NAME,false))
         someObjectsCouldNotBeDropped = true;
   }

   if (someObjectsCouldNotBeDropped)
   {
      CmpCommon::diags()->clear();
      
      *CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_DROP_SCHEMA)
                          << DgSchemaName(catName + "." + schName);
      return;
   }
   
// Verify all objects in the schema have been dropped.   
   str_sprintf(query,"SELECT COUNT(*) "
                     "FROM %s.\"%s\".%s "
                     "WHERE catalog_name = '%s' AND schema_name = '%s' AND "
                     "object_name <> '"SEABASE_SCHEMA_OBJECTNAME"'" 
                     "FOR READ COMMITTED ACCESS",
               getSystemCatalog(),SEABASE_MD_SCHEMA,SEABASE_OBJECTS,
               (char*)catName.data(),(char*)schName.data());
               
int32_t length = 0;
int32_t rowCount = 0;

   cliRC = cliInterface.executeImmediate(query,(char*)&rowCount,&length,NULL);
  
   if (cliRC < 0)
   {
      cliInterface.retrieveSQLDiagnostics(CmpCommon::diags());
      return;
   }
   
   if (rowCount > 0)
   {
      CmpCommon::diags()->clear();
      
      *CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_DROP_SCHEMA)
                          << DgSchemaName(catName + "." + schName);
      return;
   }
   
// After all objects in the schema have been dropped, drop the schema object itself.
    
char buf [1000];

   str_sprintf(buf,"DELETE FROM %s.\"%s\".%s "
                   "WHERE CATALOG_NAME = '%s' AND SCHEMA_NAME = '%s' AND " 
                   "OBJECT_NAME = '"SEABASE_SCHEMA_OBJECTNAME"'",
               getSystemCatalog(),SEABASE_MD_SCHEMA,SEABASE_OBJECTS,
               (char*)catName.data(),(char*)schName.data());
   cliRC = cliInterface.executeImmediate(buf);
   if (cliRC < 0) 
      *CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_DROP_SCHEMA)
                          << DgSchemaName(catName + "." + schName);
    
}
// *****************************************************************************
// *                                                                           *
// * Function: CmpSeabaseDDL::addSchemaObject                                  *
// *                                                                           *
// *    Inserts a schema object row into the OBJECTS table.                    *
// *                                                                           *
// *****************************************************************************
// *                                                                           *
// *  Parameters:                                                              *
// *                                                                           *
// *  <cliInterface>                  ExeCliInterface &               In       *
// *    is a reference to an Executor CLI interface handle.                    *
// *                                                                           *
// *  <schemaName>                    const ComSchemaName &           In       *
// *    is a reference to a ComSchemaName instance.  The catalog name must be  *
// *  set.                                                                     *
// *                                                                           *
// *  <schemaClass>                   ComSchemaClass                  In       *
// *    is the class (private or shared) of the schema to be added.            *
// *                                                                           *
// *  <ownerID>                       Int32                           In       *
// *    is the authorization ID that will own the schema.                      *
// *                                                                           *
// *  <ignoreIfExists>                NABoolean                       In       *
// *    do not return an error is schema already exists                        *
// *****************************************************************************
// *                                                                           *
// * Returns: PrivStatus                                                       *
// *                                                                           *
// *   0: Schema as added                                                      *
// *  -1: Schema was not added.  A CLI error is put into the diags area.       *
// *                                                                           *
// *****************************************************************************
int CmpSeabaseDDL::addSchemaObject(
   ExeCliInterface & cliInterface,
   const ComSchemaName & schemaName,
   ComSchemaClass schemaClass,
   Int32 ownerID,
   NABoolean ignoreIfExists)
   
{

NAString catalogName = schemaName.getCatalogNamePartAsAnsiString();
ComAnsiNamePart schemaNameAsComAnsi = schemaName.getSchemaNamePart();
NAString schemaNamePart = schemaNameAsComAnsi.getInternalName();

ComObjectName objName(catalogName,schemaNamePart,NAString(SEABASE_SCHEMA_OBJECTNAME), 
                      COM_TABLE_NAME,TRUE);
                      
   if (isSeabaseReservedSchema(objName) &&
       !Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL))
   {
      *CmpCommon::diags() << DgSqlCode(-CAT_RESERVED_METADATA_SCHEMA_NAME)
                          << DgSchemaName(schemaName.getExternalName().data());
      return -1;
   }
                      
NAString objectNamePart = objName.getObjectNamePartAsAnsiString(TRUE);

Lng32 retcode = existsInSeabaseMDTable(&cliInterface,catalogName,schemaNamePart, 
                                       objectNamePart, COM_UNKNOWN_OBJECT, FALSE);
   if (retcode < 0)
      return -1;
  
   if (retcode == 1 ) // already exists
   {
      if (ignoreIfExists)
        return 0;
      else
        *CmpCommon::diags() << DgSqlCode(-CAT_SCHEMA_ALREADY_EXISTS)
                            << DgSchemaName(schemaName.getExternalName().data());
      return -1;
   }

char buf[4000];

ComUID schemaUID;

   schemaUID.make_UID();
   
Int64 schemaObjectUID = schemaUID.get_value();
  
Int64 createTime = NA_JulianTimestamp();

NAString quotedSchName;
NAString quotedObjName;

   ToQuotedString(quotedSchName,schemaNamePart,FALSE);
   ToQuotedString(quotedObjName,NAString(SEABASE_SCHEMA_OBJECTNAME),FALSE);

char schemaObjectLit[3] = {0};
   
   switch (schemaClass)
   {
      case COM_SCHEMA_CLASS_PRIVATE:
      {
         strncpy(schemaObjectLit,COM_PRIVATE_SCHEMA_OBJECT_LIT,2);
         break;
      }
      case COM_SCHEMA_CLASS_SHARED:
      {
         strncpy(schemaObjectLit,COM_SHARED_SCHEMA_OBJECT_LIT,2);
         break;
      }
      case COM_SCHEMA_CLASS_DEFAULT:
      default:
      {
         // Schemas are private by default, but could choose a different
         // default class here based on CQD or other attribute.
         strncpy(schemaObjectLit,COM_PRIVATE_SCHEMA_OBJECT_LIT,2);
         break;
      } 
   }
   
   str_sprintf(buf, "insert into %s.\"%s\".%s values ('%s', '%s', '%s', '%s', %Ld, %Ld, %Ld, '%s', '%s', %d, %d, 0)",
               getSystemCatalog(),SEABASE_MD_SCHEMA,SEABASE_OBJECTS,
               catalogName.data(), quotedSchName.data(), quotedObjName.data(),
               schemaObjectLit,
               schemaObjectUID,
               createTime, 
               createTime,
               COM_YES_LIT, // valid_def
               COM_NO_LIT,  // droppable
               ownerID,ownerID);
               
Int32 cliRC = cliInterface.executeImmediate(buf);
   
   if (cliRC < 0)
   {
      cliInterface.retrieveSQLDiagnostics(CmpCommon::diags());
      return -1;
   }

   return 0;

}
std::vector<RunwayExitInSim*> CRunwayExitAssignmentStrategiesInSim::GetRunwayExitByFlightType( AirsideFlightInSim *pFlight,CAirportDatabase *pAirportDatabase ,StandResourceManager* pStandResManager ,bool bCheckCanHold)
{
	StandInSim* pStand = pFlight->GetOperationParkingStand();
	if (pStand == NULL)
		pStand = pFlight->GetPlanedParkingStand(ARR_PARKING);

	LogicRunwayInSim* pLogicRunway = pFlight->GetLandingRunway();
	int nCount = m_pRunwayExitStrategies->GetStrategyCount();

	if (pStand == NULL && nCount > 0&&!pFlight->IsCircuitFlight())
	{
		CString strWarn;
		strWarn.Format("No assigned parking stand, without available runway exit strategy!") ;
		CString strError = _T("DEFINE ERROR");
		AirsideSimErrorShown::SimWarning(pFlight,strWarn,strError);	
	}

	ALTObjectID standName;
	if(pStand)
		standName = pStand->GetStandInput()->GetObjectName();

	FlightTypeRunwayExitStrategyItem* pItem = NULL;
	RunwayExitStandStrategyItem* pStandItem = NULL;

	for ( int i =0; i < nCount; i++)
	{
		FlightConstraint fltCnst = m_pRunwayExitStrategies->GetStrategyItem(i)->getFlightType();
		if(	pFlight->fits(fltCnst) )
		{
			pItem = m_pRunwayExitStrategies->GetStrategyItem(i);
			if (pItem)
			{
				int nItemCount = pItem->GetRunwayExitStandStrategyCount();
				CString strName;
				for (int j =0; j < nItemCount; j++)
				{
					RunwayExitStandStrategyItem* pData = pItem->GetRunwayExitStandStrategyItem(j);
					strName = pData->getStandFamilyName();
					if (strName.CompareNoCase("All") ==0)
					{
						pStandItem = pData;
						break;
					}

					ALTObjectID objName(strName);
					if (standName.idFits(objName))
					{
						pStandItem = pData;
						break;
					}
				}
			}
			if (pStandItem)//find the best item
				break;
		}	
	}

	if (pStandItem)
	{
		TimeRangeRunwayExitStrategyItem* pTimeItem = NULL;
		nCount = pStandItem->GetTimeRangeStrategyItemCount();
		for (int i =0; i < nCount; i++)
		{
			ElapsedTime tStart = pStandItem->GetTimeRangeStrategyItem(i)->getStartTime();
			ElapsedTime tEnd = pStandItem->GetTimeRangeStrategyItem(i)->getEndTime();
			if (pFlight->GetTime() >= tStart && pFlight->GetTime() <= tEnd)
			{
				pTimeItem = pStandItem->GetTimeRangeStrategyItem(i); 
				break;
			}
		}

		if (pTimeItem)
		{
			switch(pTimeItem->getStrategyType())
			{
				case MaxBrakingFirstOnEitherSide:
					 return VerifyFlightExits(GetMaxBrakingFirstExitOnEitherSide(pFlight,pLogicRunway),pFlight,bCheckCanHold);						 
					
				case MaxBrakingFirstOnSameSideAsArrivalGate:
					 return VerifyFlightExits( GetMaxBrakingFirstExitOnSameSideAsArrivalGate(pFlight,pLogicRunway,pStandResManager),pFlight,bCheckCanHold);

				case NormalBrakingExitOnEitherSide:
					 return VerifyFlightExits(GetNormalBrakingExitOnEitherSide(pFlight, pLogicRunway),pFlight,bCheckCanHold);

				case NormalBrakingExitOnSameSide:
					 return VerifyFlightExits(GetNormalBrakingExitOnSameSideAsArrivalGate(pFlight, pLogicRunway,pStandResManager),pFlight,bCheckCanHold);

				case ManagedExit:
					 return GetManagedExit(pFlight,pLogicRunway,pTimeItem, bCheckCanHold);

				default:
					break;
			}
		}
	}

	if (nCount > 0)
	{
		CString strWarn;
		strWarn.Format("No available exits for the flight according to Runway Exit Assignment Strategies") ;
		CString strError = _T("DEFINE ERROR");
		AirsideSimErrorShown::SimWarning(pFlight,strWarn,strError);	
	}

	std::vector<RunwayExitInSim*> vExits;
	vExits.clear();
	vExits = VerifyFlightExits( GetNormalBrakingExitOnSameSideAsArrivalGate(pFlight,pLogicRunway,pStandResManager),pFlight,bCheckCanHold);

	if (vExits.empty())
	{
		 vExits = VerifyFlightExits( GetMaxBrakingFirstExitOnSameSideAsArrivalGate(pFlight,pLogicRunway,pStandResManager),pFlight,bCheckCanHold);
	}

	return vExits;
}
bool CRunwayExitAssignmentStrategiesInSim::IsBackTrackOp(AirsideFlightInSim* pFlight)
{
	LogicRunwayInSim* pLogicRunway = pFlight->GetLandingRunway();
	StandInSim* pStand = pFlight->GetOperationParkingStand();
	if (pStand == NULL)
		pStand = pFlight->GetPlanedParkingStand(ARR_PARKING);

	if (pStand == NULL)
		return false;

	FlightTypeRunwayExitStrategyItem* pItem = NULL;
	RunwayExitStandStrategyItem* pStandItem = NULL;

	int nCount = m_pRunwayExitStrategies->GetStrategyCount();
	for ( int i =0; i < nCount; i++)
	{
		FlightConstraint fltCnst = m_pRunwayExitStrategies->GetStrategyItem(i)->getFlightType();
		if(	pFlight->fits(fltCnst) )
		{
			pItem = m_pRunwayExitStrategies->GetStrategyItem(i);
			if (pItem)
			{
				int nItemCount = pItem->GetRunwayExitStandStrategyCount();
				for (int j =0; j < nItemCount; j++)
				{
					RunwayExitStandStrategyItem* pData = pItem->GetRunwayExitStandStrategyItem(j);
					CString strName = pData->getStandFamilyName();
					if (strName.CompareNoCase("All") ==0)
					{
						pStandItem = pData;
						break;
					}

					ALTObjectID objName(strName);
					if (pStand->GetStandInput()->GetObjectName().idFits(objName))
					{
						pStandItem = pData;
						break;
					}
				}
			}
			if(pStandItem)
				break;

		}	
	}

	if (pStandItem)
	{
		TimeRangeRunwayExitStrategyItem* pTimeItem = NULL;
		nCount = pStandItem->GetTimeRangeStrategyItemCount();
		for (int i =0; i < nCount; i++)
		{
			ElapsedTime tStart = pStandItem->GetTimeRangeStrategyItem(i)->getStartTime();
			ElapsedTime tEnd = pStandItem->GetTimeRangeStrategyItem(i)->getEndTime();
			if (pFlight->GetTime() >= tStart && pFlight->GetTime() <= tEnd)
			{
				pTimeItem = pStandItem->GetTimeRangeStrategyItem(i); 
				break;
			}
		}

		if (pTimeItem)
		{
			int nRunwayID = pFlight->GetLandingRunway()->GetRunwayInSim()->GetRunwayInput()->getID();
			int nRunwayMark = pFlight->GetLandingRunway()->getLogicRunwayType();

			if(pTimeItem->getStrategyType() == ManagedExit && pTimeItem->getStrategyManagedExitMode() == TimeRangeRunwayExitStrategyItem::ProbabilityBased)
			{
				RunwayExitStrategyPercentItem* pRwyExitItem = pTimeItem->GetRunwayExitPercentItem(nRunwayID,nRunwayMark);
				RunwayExitPercentVector vExit = pRwyExitItem->getItems();

				int nCount = int(vExit.size());
				for ( int i = 0; i< nCount; i++ )
				{
					if (vExit[i]->getExitID() == pFlight->GetRunwayExit()->GetID())
						return vExit[i]->IsBacktrack();				 
				}
			}
			else
			{
				RunwayExitStrategyPriorityItem* pRwyExitItem = pTimeItem->GetRunwayExitPriorityItem(nRunwayID,nRunwayMark);
				RunwayExitStrategyPriorityVector vExit = pRwyExitItem->getItems();

				int nCount = int(vExit.size());
				for ( int i = 0; i< nCount; i++ )
				{
					if (vExit[i]->getExitID() == pFlight->GetRunwayExit()->GetID())
						return vExit[i]->IsBacktrack();				 
				}
			}
		}
	}
	return false;
}
Exemplo n.º 19
0
inline QByteArray retrieveObjectName(PyObject* obj)
{
    Shiboken::AutoDecRef objName(PyObject_Str(obj));
    return Shiboken::String::toCString(objName);
}