Beispiel #1
0
const char* IPropertySet::GetSTRING(const void* pData, int nIndex)
{
	assert(nIndex>=0 && nIndex<PropertyCount());
	if(nIndex<0 || nIndex>=PropertyCount()) return NULL;
	IProperty* pInfo = GetProperty(nIndex);
	assert(pInfo->GetType()==PROPERTY_TYPE_STRING);
	if(pInfo->GetType()!=PROPERTY_TYPE_STRING) return NULL;
	return (const char*)pData + pInfo->GetOffset();
}
Beispiel #2
0
unsigned int IPropertySet::GetDWORD(const void* pData, int nIndex)
{
	assert(nIndex>=0 && nIndex<PropertyCount());
	if(nIndex<0 || nIndex>=PropertyCount()) return -1;
	IProperty* pInfo = GetProperty(nIndex);
	assert(pInfo->GetType()==PROPERTY_TYPE_DWORD);
	if(pInfo->GetType()!=PROPERTY_TYPE_DWORD) return -1;
	return *((unsigned int*)((char*)pData + pInfo->GetOffset()));
}
Beispiel #3
0
float IPropertySet::GetFLOAT(const void* pData, int nIndex)
{
	assert(nIndex>=0 && nIndex<PropertyCount());
	if(nIndex<0 || nIndex>=PropertyCount()) return -1;
	IProperty* pInfo = GetProperty(nIndex);
	assert(pInfo->GetType()==PROPERTY_TYPE_FLOAT);
	if(pInfo->GetType()!=PROPERTY_TYPE_FLOAT) return -1;
	return *((float*)((char*)pData + pInfo->GetOffset()));
}
Beispiel #4
0
bool IPropertySet::SetValue(void* pData, int nIndex, char Value)
{
	assert(nIndex>=0 && nIndex<PropertyCount());
	if(nIndex<0 || nIndex>=PropertyCount()) return false;
	IProperty* pInfo = GetProperty(nIndex);
	assert(pInfo->GetType()==PROPERTY_TYPE_CHAR);
	if(pInfo->GetType()!=PROPERTY_TYPE_CHAR) return false;
	*((char*)((char*)pData + pInfo->GetOffset())) = Value;
	return true;
}
Beispiel #5
0
	void IObject::SetPropertyValue(Core::IString Name,Core::IString Value)
	{
		IProperty *prop = m_aProperties.GetProperty(Name);

		if (prop)
		{
			prop->SetValueFromString(Value);
			OnPropertyChange(Name);
		}
	}
void IProperty::setDirty(bool b)
{
	if (isFake()) {
		IProperty *p = parent();
		while (p != 0 && p->isFake())
			p = p->parent();
		if (p != 0)
			p->setDirty(true);
	} else {
		m_dirty = b;
	}
}
Beispiel #7
0
int CGamesysManager::CreateNewArchetype(int donorArch, const char* name)
{
	int newArch = g_pObjSys->BeginCreate(donorArch, 2);

	g_pObjSys->NameObject(newArch, name);
	IProperty* donorProp = g_pPropMan->GetPropertyNamed("DonorType");

	if (donorProp->IsSimplyRelevant(donorArch))
	{
		donorProp->Copy(newArch, donorArch);
	}

	g_pObjSys->EndCreate(newArch);

	if (!newArch)
		Log.Print("acache: Failed to create %s.", name);

	return newArch;
}
//! fills the property with children - must be called after the array has been inserted to the property list
void wxArrayProperty::Fill(ArrayProperty* pProperty)
{
	s32 numProperties = pProperty->GetProperties().size();
	for(s32 i=0; i<numProperties; ++i)
	{
		IProperty* pSubProperty = pProperty->GetProperties()[i];

		std::stringstream ss;
		ss << "[" << i << "]";
		pSubProperty->SetName(ss.str());

		wxPGProperty* pWxProperty = PropertyList::GetWxProperty(pSubProperty, m_pParent);
		InsertChild(-1, pWxProperty);
		bool bParentDisabled = !GetGrid()->IsPropertyEnabled(this);
		if(bParentDisabled)
		{
			GetGrid()->DisableProperty(pWxProperty);
		}
	}

	UpdateValue();
}
bool PropertyBag::GetNext(
   gubi::IProperty** ppProperty )
{
   bool bReturn = false;

   if (ppProperty != NULL && m_mapIterator != m_mapProperty.end())
   {
      IProperty* pProperty = m_mapIterator->second;

      if (pProperty != NULL)
      {
         pProperty->AddReference();
      }

      *ppProperty = pProperty;
      bReturn     = true;

      m_mapIterator++;
   }

   return bReturn;
}
bool PropertyBag::Find(
   const gubi::Identifier& ePropertyId,
   gubi::IProperty** ppProperty )
{
   bool bReturn              = false;
   property_map::iterator it = m_mapProperty.find(ePropertyId);

   if (ppProperty != NULL && it != m_mapProperty.end())
   {
      IProperty* pProperty = it->second;

      if (pProperty != NULL)
      {
         pProperty->AddReference();
      }

      *ppProperty = pProperty;
      bReturn     = true;
   }

   return bReturn;
}
Beispiel #11
0
bool IPropertySet::SetValue(void* pData, int nIndex, const char* Value)
{
	assert(nIndex>=0 && nIndex<PropertyCount());
	if(nIndex<0 || nIndex>=PropertyCount()) return false;
	IProperty* pInfo = GetProperty(nIndex);
	assert(pInfo->GetType()==PROPERTY_TYPE_FLOAT);
	if(pInfo->GetType()!=PROPERTY_TYPE_FLOAT) return false;
	unsigned int len = strlen(Value);
	assert(len<=pInfo->GetSize());
	if(len>pInfo->GetSize()) return false;
	memcpy((char*)pData+pInfo->GetOffset(), Value, len+1);
	return true;
}
Beispiel #12
0
RESULT
Animation::BindTo( IProperty& property )
{
    RESULT rval = S_OK;
   
    if (property.IsNull())
    {
        SAFE_DELETE(m_pTargetProperty);
        m_isBoundToProperty = false;
        Stop();
        
        goto Exit;
    }

    
    if (property.GetType() != m_propertyType)
    {
        RETAILMSG(ZONE_ERROR, "ERROR: Animation::BindTo( \"%s\", 0x%x ): target Property type 0x%x incorrect for this Animation",
                  m_name.c_str(), (UINT32)&property, property.GetType());
        rval = E_INVALID_OPERATION;
        goto Exit;
    }
    

    SAFE_DELETE(m_pTargetProperty);
    m_pTargetProperty   = property.Clone();
    m_isBoundToProperty = true;    
    
    if (m_relativeToCurrentState)
    {
        // Save the target Property into our m_startingValue.
        // Keyframes will be interpolated, then added to m_startingValue to produce the final result.
        switch (m_keyFrameType)
        {
            case KEYFRAME_TYPE_UINT32:
                m_startingValue.SetIntValue( m_pTargetProperty->GetInteger() );
                break;
            case KEYFRAME_TYPE_FLOAT:
                m_startingValue.SetFloatValue( m_pTargetProperty->GetFloat() );
                break;
            case KEYFRAME_TYPE_VEC2:
                m_startingValue.SetVec2Value( m_pTargetProperty->GetVec2() );
                break;
            case KEYFRAME_TYPE_VEC3:
                m_startingValue.SetVec3Value( m_pTargetProperty->GetVec3() );
                break;
            case KEYFRAME_TYPE_VEC4:
                m_startingValue.SetVec4Value( m_pTargetProperty->GetVec4() );
                break;
            case KEYFRAME_TYPE_COLOR:
                m_startingValue.SetColorValue( m_pTargetProperty->GetColor() );
                break;
            default:
                DEBUGCHK(0);
                break;
        }
    }


Exit:
    return rval;
}
Beispiel #13
0
//-----------------------------------------------------------------------------
int configGenerator::genConfig( const Strings_t& libs, const string& userModule )
//-----------------------------------------------------------------------------
{
  //--- Disable checking StatusCode -------------------------------------------
  StatusCode::disableChecking();

  const Strings_t::const_iterator endLib = libs.end();

  const std::string gaudiSvc = "GaudiCoreSvc";
  const bool isGaudiSvc = ( std::find( libs.begin(), endLib, gaudiSvc ) != endLib );

  //--- Instantiate ApplicationMgr --------------------------------------------
  if ( !isGaudiSvc && createAppMgr() ) {
    cout << "ERROR: ApplicationMgr can not be created. Check environment" << endl;
    return EXIT_FAILURE;
  }

  //--- Iterate over component factories --------------------------------------
  Scope factories = Scope::ByName(PLUGINSVC_FACTORY_NS);
  if ( !factories ) {
    cout << "ERROR: No PluginSvc factory namespace could be found" << endl;
    return EXIT_FAILURE;
  }

  ISvcLocator* svcLoc = Gaudi::svcLocator();
  IInterface*  dummySvc = new Service( "DummySvc", svcLoc );
  dummySvc->addRef();

  bool allGood = true;

  // iterate over all the requested libraries
  for ( Strings_t::const_iterator iLib=libs.begin(); iLib != endLib; ++iLib ) {

    std::cout << ":::: processing library: " << *iLib << "..." << std::endl;

    // reset state
    m_importGaudiHandles = false;
    m_pyBuf.str("");
    m_dbBuf.str("");

    // Scan the pluginSvc namespace and store the "background" of already
    // alive components, so we can extract our signal later on
    set<string> bkgNames;
    if ( !isGaudiSvc ) {
      for ( Member_Iterator it = factories.FunctionMember_Begin();
            it != factories.FunctionMember_End(); ++it ) {
        string ident = getId(*it);
        if ( PluginService::Debug() > 0 ) {
          cout << "::: " << ident << endl;
        }
        bkgNames.insert( ident );
      }
    }
    const set<string>::const_iterator bkgNamesEnd = bkgNames.end();

    //--- Load component library ----------------------------------------------
    System::ImageHandle handle;
    unsigned long err = System::loadDynamicLib( *iLib, &handle );
    if ( err != 1 ) {
      cout << "ERROR: " << System::getLastErrorString() << endl;
      allGood = false;
      continue;
    }

    for ( Member_Iterator it = factories.FunctionMember_Begin();
          it != factories.FunctionMember_End();
          ++it ) {
      const string ident = getId(*it);
      if ( bkgNames.find(ident) != bkgNamesEnd ) {
        if ( PluginService::Debug() > 0 ) {
          cout << "\t==> skipping [" << ident << "]..." << endl;
        }
        continue;
      }

      // Atlas contributed code (patch #1247)
      // Skip the generation of configurables if the component does not come
      // from the same library we are processing (i.e. we found a symbol that
      // is coming from a library loaded by the linker).
      // Windows implementation is empty.
      if ( !DsoUtils::inDso( *it, DsoUtils::libNativeName(*iLib) ) ) {
        cout << "WARNING: library [" << *iLib << "] requested factory "
        << "from another library ["
        << DsoUtils::dsoName(*it) << "]"
        << " ==> [" << ident << "] !!"
        << endl;
        continue;
      }

      const string rtype = it->TypeOf().ReturnType().Name();
      string type;
      bool known = true;
      if      ( ident == "ApplicationMgr" ) type = "ApplicationMgr";
      else if ( rtype == "IInterface*" )    type = "IInterface";
      else if ( rtype == "IAlgorithm*" )    type = "Algorithm";
      else if ( rtype == "IService*" )      type = "Service";
      else if ( rtype == "IAlgTool*" )      type = "AlgTool";
      else if ( rtype == "IAuditor*" )      type = "Auditor";
      else if ( rtype == "IConverter*" )    type = "Converter";
      else if ( rtype == "DataObject*" )    type = "DataObject";
      else                                  type = "Unknown", known = false;
      string name = ident;
      // handle possible problems with templated components
      boost::trim(name);

      cout << " - component: " << name << endl;

      if ( type == "IInterface" ) {
        /// not enough information...
        /// skip it
        continue;
      }

      if ( type == "Converter" || type == "DataObject" ) {
        /// no Properties, so don't bother create Configurables...
        continue;
      }

      //if ( type == "ApplicationMgr" ) {
      ///  @FIXME: no Configurable for this component. yet...
      ///  continue;
      //}

      if ( !known ) {
        cout << "WARNING: Unknown (return) type [" << rtype << "] !!\n"
             << "WARNING: component [" << ident << "] is skipped !"
             << endl;
        allGood = false;
        continue;
      }

      string cname = "DefaultName";
      vector<void*>  args;
      args.reserve( 3 );
      if ( type == "AlgTool" ) {
        args.resize( 3 );
        args[0] = &cname;
        args[1] = &type;
        args[2] = dummySvc;
      }
      else {
        args.resize( 2 );
        args[0] = &cname;
        args[1] = svcLoc;
      }
      IProperty* prop = 0;
      try {
        if ( type == "Algorithm" ) {
          prop = makeInstance<IAlgorithm>(*it,args);
        }
        else if ( type == "Service") {
          prop = makeInstance<IService>(*it,args);
        }
        else if ( type == "AlgTool") {
          prop = makeInstance<IAlgTool>(*it,args);
        }
        else if ( type == "Auditor") {
          prop = makeInstance<IAuditor>(*it,args);
        }
        else if ( type == "ApplicationMgr") {
          //svcLoc->queryInterface(IProperty::interfaceID(), pp_cast<void>(&prop));
          svcLoc->queryInterface(IProperty::interfaceID(), (void**)(&prop));
        }
        else {
          prop = makeInstance<IInterface>(*it,args);
        }
      }
      catch ( exception& e ) {
        cout << "ERROR: Error instantiating " << name
             << " from " << *iLib << endl;
        cout << "ERROR: Got exception: " << e.what() << endl;
        allGood = false;
        continue;
      }
      catch ( ... ) {
        cout << "ERROR: Error instantiating " << name
             << " from " << *iLib << endl;
        allGood = false;
        continue;
      }
      if( prop ) {
        if (genComponent( *iLib, name, type, prop->getProperties() )) {
          allGood = false;
        }
        prop->release();
      } else {
        cout << "ERROR: could not cast IInterface* object to an IProperty* !\n"
             << "ERROR: return type from PluginSvc is [" << rtype << "]...\n"
             << "ERROR: NO Configurable will be generated for ["
             << name << "] !"
             << endl;
        allGood = false;
      }
    } //> end loop over factories

    ///
    /// write-out files for this library
    ///
    const std::string pyName = ( fs::path(m_outputDirName) /
                  fs::path(*iLib+"Conf.py") ).string();
    const std::string dbName = ( fs::path(m_outputDirName) /
                  fs::path(*iLib+"_confDb.py") ).string();

    std::fstream py( pyName.c_str(),
              std::ios_base::out|std::ios_base::trunc );
    std::fstream db( dbName.c_str(),
              std::ios_base::out|std::ios_base::trunc );

    genHeader ( py, db );
    if (!userModule.empty()) 
      py << "from " << userModule << " import *" <<endl;
    genBody   ( py, db );
    genTrailer( py, db );

  } //> end loop over libraries

  dummySvc->release();
  dummySvc = 0;

  return allGood ? EXIT_SUCCESS : EXIT_FAILURE;
}
bool wxArrayPropertyEditor::OnEvent( wxPropertyGrid* propGrid,
                                     wxPGProperty* property,
                                     wxWindow* ctrl,
                                     wxEvent& event ) const
{
    if ( event.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED )
    {
        wxPGMultiButton* buttons = (wxPGMultiButton*) propGrid->GetEditorControlSecondary();
		wxArrayProperty* pArrayProperty = static_cast<wxArrayProperty*>(property);

		if(event.GetId() == buttons->GetButtonId(0)) // + - add element
		{
			if(pArrayProperty->GetMaxElems() < 0
			|| pArrayProperty->GetChildCount() < u32(pArrayProperty->GetMaxElems()))
			{
				// determine new property name
				IProperty* pNewProperty = pArrayProperty->GetSubPropertyTemplate();
				std::stringstream ss;
				ss << "[" << property->GetChildCount() << "]";
				pNewProperty->SetName(ss.str());

				// create a new wxPGProperty out of it and insert it
				wxPGProperty* pWxProperty = PropertyList::GetWxProperty(pNewProperty, pArrayProperty->GetParent());
				property->InsertChild(-1, pWxProperty);

				if(pNewProperty->GetType() == PT_Reference)
				{
					pArrayProperty->GetParent()->FillArrayProperties(pNewProperty, pWxProperty);	
				}

				pArrayProperty->UpdateValue();
				propGrid->RefreshProperty(property);			

				// update the corresponding property in the property stream
				wxPropertyGridEvent PGEvent;
				PGEvent.SetProperty(property);
				pArrayProperty->SetEventType(wxArrayProperty::E_PropertyAdded);
				pArrayProperty->GetParent()->OnPropertyGridChange(PGEvent);
			}			
		}	
		else if(event.GetId() == buttons->GetButtonId(1)) // - remove element
		{
			int childCount = property->GetChildCount();
			if(childCount > 0)
			{
				// remove the wx property
				wxPGProperty* pChild = property->Item(childCount-1);
				propGrid->DeleteProperty(pChild);	
				pArrayProperty->UpdateValue();
				propGrid->RefreshProperty(property);

				// update the corresponding property in the property stream
				wxPropertyGridEvent PGEvent;
				PGEvent.SetProperty(property);
				pArrayProperty->SetEventType(wxArrayProperty::E_PropertyRemoved);
				pArrayProperty->GetParent()->OnPropertyGridChange(PGEvent);
			}
		}

		return true;
    }
	else
	{
		return wxPGTextCtrlEditor::OnEvent(propGrid, property, ctrl, event);
	}    
}
Beispiel #15
0
LRESULT 
CAppOptAdvancedPage::OnTreeNotify(LPNMHDR pnmh)
{
	BOOL fSuccess = FALSE;
	// pnmh->hwndFrom;
	
	if (IDC_OPTION_TREE != pnmh->idFrom) {
		// ignore other notification
		SetMsgHandled(FALSE);
		return TRUE;
	}

	if (PIN_ITEMCHANGING != pnmh->code) {
		// ignore notifications other than PIN_CLICK
		SetMsgHandled(FALSE);
		return TRUE;
	}

	LPNMPROPERTYITEM pnmProp = reinterpret_cast<LPNMPROPERTYITEM>(pnmh);
	if (NULL == pnmProp->prop) {
		SetMsgHandled(FALSE);
		return TRUE;
	}

	IProperty* prop = pnmProp->prop;

	if (NDASSVC_SUSPEND_ALLOW == prop->GetItemData())
	{
		VARIANT varValue;
		::VariantInit(&varValue);
		fSuccess = prop->GetValue(&varValue);
		ATLASSERT(fSuccess);
		ATLASSERT(varValue.vt = VT_BOOL);
		if (!fSuccess || VT_BOOL != varValue.vt) {
			::VariantClear(&varValue);
			SetMsgHandled(FALSE);
			return TRUE;
		}

		//
		// Ignore the status of already checked.
		//
		if (varValue.boolVal) {
			::VariantClear(&varValue);
			SetMsgHandled(FALSE);
			return TRUE;
		}
		::VariantClear(&varValue);

		int response = AtlMessageBox(
			m_hWnd,
			IDS_SUSPEND_WARNING,
			IDS_MAIN_TITLE,
			MB_YESNO | MB_ICONWARNING | MB_DEFBUTTON2);

		if (IDYES != response) 
		{
			SetMsgHandled(TRUE);
			return TRUE;
		}
	}

	SetMsgHandled(FALSE);
	return TRUE;
}