/**
 * Perform an interpret call where we want to return a container that 
 * contains flattened containers (flattened by 1).
 *
 * @param environment Not used.
 * @param parms The parameters passed to the builtin function.
 * @param additional_parameter Not used.
 * @return a container of elements.
 *
 * @version
 * - JR Lewis       2012.06.01
 *   - Initial version.
 */
Element ConcatBuiltinImplementation::Interpret_( Environment& /* environment */ 
                                               , std::vector<Element> const& parms
                                               , Element const& /* additional_parameter */ )
{
    typedef std::vector<Element>::const_iterator Iterator;

    Container C;

    Iterator iter = parms.begin();
    Iterator end = parms.end();
    for(; iter != end; ++iter)
    {
        bool isAContainer  = false;
        Container current = CastToContainer(*iter, isAContainer);
        if (isAContainer)
        {
            int const NUMBER_OF_ELEMENTS = current.NumberOfElements();
            for(int i=0; i<NUMBER_OF_ELEMENTS; ++i)
            {
                C.Add(current.Get(i));
            }
        } 
        else
        {
            C.Add(*iter);
        }
    }

    return C;
}
Beispiel #2
0
static void CreateBitmapWindow(Container& owner, TitleBitmapWindow*& bitmap, /*IceGroupBox*& group,*/ TitleWindow* parent, sdword x, sdword y, udword width, udword height, const char* label)
{
	const udword OffsetY = 4;	// ### not sure why this is needed

	// Create bitmap window
	WindowDesc WD;
	WD.mParent	= parent;
	WD.mX		= x + GROUP_BOX_BORDER_SIZE;
	WD.mY		= y + GROUP_BOX_BORDER_SIZE + OffsetY;
	WD.mWidth	= width;
	WD.mHeight	= height;
	WD.mLabel	= "BitmapWindow";
	WD.mType	= WINDOW_POPUP;
	WD.mStyle	= WSTYLE_NORMAL;
// ### the better style works but not all pixels get displayed
//	WD.mStyle	= WSTYLE_CLIENT_EDGES|WSTYLE_STATIC_EDGES;
	bitmap = ICE_NEW(TitleBitmapWindow)(WD);
	bitmap->SetVisible(true);
	bitmap->mMainW = parent;
	owner.Add(udword(bitmap));

/*	if(0)
	{
		GroupBoxDesc GBD;
		GBD.mParent	= parent;
		GBD.mX		= x;
		GBD.mY		= y;
		GBD.mWidth	= width + GROUP_BOX_BORDER_SIZE*2;
		GBD.mHeight	= height + GROUP_BOX_BORDER_SIZE*2 + OffsetY;
		GBD.mLabel	= label;
		group = ICE_NEW(IceGroupBox)(GBD);
		owner.Add(udword(group));
	}
	else*/
	{
		EditBoxDesc EBD;
		EBD.mParent		= parent;
		EBD.mX			= x;
		EBD.mY			= y;
		EBD.mWidth		= width + GROUP_BOX_BORDER_SIZE*2;
		EBD.mHeight		= height + GROUP_BOX_BORDER_SIZE*2 + OffsetY;
		EBD.mLabel		= label;
		EBD.mFilter		= EDITBOX_TEXT;
		EBD.mType		= EDITBOX_READ_ONLY;
		IceEditBox* EB = ICE_NEW(IceEditBox)(EBD);
		EB->SetVisible(true);
		owner.Add(udword(EB));
	}
}
Beispiel #3
0
STATUS
UserManager::EnumTableReplyHandler( void*, STATUS ){

	UserAccessTableEntry		*pRow = (UserAccessTableEntry *)m_pTemp;
	User						*pUser;
	Container					*pContainer;

	if( m_shouldReinit ){
		m_shouldReinit = false;
		delete m_pTemp;
		return m_pUserTable->Enumerate( &m_pTemp, (pTSCallback_t)METHOD_ADDRESS( UserManager, EnumTableReplyHandler ), NULL );
	}

	pContainer = new SList;
	for( U32 index = 0; index < m_pUserTable->GetNumberOfRows(); index++, pRow++ ){
		pUser = new User( GetListenManager() );
		pUser->BuildYourselfFromPtsRow( pRow );
		pUser->m_pUserManager = this;
		pContainer->Add( (CONTAINER_ELEMENT)pUser );
	}
	AddObjectsIntoManagedObjectsVector( *pContainer );
	delete m_pTemp;
	delete pContainer;

	m_isIniting = m_shouldReinit = false;

	SSAPI_TRACE( TRACE_L2, "\nUserManager: ...Done! Objects built: ", GetManagedObjectCount() );
	SetIsReadyToServiceRequests( true );

	return OK;
}
    void PropertyRestrictions<Key, KeyValue, Container>::ConfigureFromJsonAndKey( const Configuration * inputJson, const std::string& key )
    {
        // Make this optional.
        if( inputJson->Exist( key ) == false )
        {
            return;
        }

        // We have a list of json objects. The format/logic is as follows. For input:
        // [
        //  { "Character": "Good", "Income": "High" },
        //  { "Character": "Bad", "Income": "Low" }
        // ]
        // We give the intervention if the individuals has
        // Good Character AND High Income OR Bad Character AND Low Income.
        // So we AND together the elements of each json object and OR together these 
        // calculated truth values of the elements of the json array.
        json::QuickInterpreter s2sarray = (*inputJson)[key].As<json::Array>();
        for( int idx=0; idx < (*inputJson)[key].As<json::Array>().Size(); idx++ )
        {
            Container container;

            auto json_map = s2sarray[idx].As<json::Object>();
            for( auto data = json_map.Begin();
                      data != json_map.End();
                      ++data )
            {
                std::string key = data->name;
                std::string value = (std::string)s2sarray[idx][key].As< json::String >();
                KeyValue kv( key, value );
                container.Add( kv );
            }
            _restrictions.push_back( container );
        }
    }
/**
 * The following method takes the path and elements passed in and creates a 
 * new ExecutorProcess_ element that will be in charge of running the 
 * program.
 *
 * @version 
 * - JR Lewis       2012.03.05
 *   - Initial version.
 */
Element ExecutorBuiltinImplementation::InterpretParsed_( Environment& environment
                                                       , Element& path_element
                                                       , std::vector<Element> const& parms) 
{
    String_* path = dynamic_cast<String_*>(path_element.ElementHandle());
    Element out;

    std::vector<Element> parameters;
    Funcall_::InterpretParameters( environment
                                 , parms
                                 , parameters );  

    if (  0 != path )
    {
        Container container;
        size_t const PARMS_SIZE = parameters.size();
        for(size_t i=0; i<PARMS_SIZE; ++i)
        {
            container.Add(parameters[i]);
        }
 
        ExecutorProcessing_* processing = new ExecutorProcessing_( this->strine
                                                                 , QString::fromStdString(path->Value())
                                                                 , container);
        out = Processing(processing); 
    } 
    return out;
}
 void PropertyRestrictions<Key, KeyValue, Container>::Add( std::map< std::string, std::string >& rMap )
 {
     Container container;
     for( auto& entry : rMap )
     {
         KeyValue kv( entry.first, entry.second );
         container.Add( kv );
     }
     _restrictions.push_back( container );
 }
        Element InterpretContainer_( Container container
                                   , Environment&
                                   , std::vector<Element> const& elements)
        {
            Container newContainer = container.Copy();
            
            size_t const SIZE = elements.size();
            for(size_t i=0; i<SIZE; ++i)
            {
                newContainer.Add(elements[i]);
            } 

            return newContainer;
        }
Element FileAttributesBuiltinImplementation::Interpret_( Environment&
        , std::vector<strine::Element> const& parms
        , Element const& )
{
    Container out;
    QString filename;
    if (1 >= parms.size())
    {
        bool success = false;
        String s = CastToString(parms[0], success);
        if (success)
        {
            filename = QString::fromStdString(s.Value());
        }
    }

    QFileInfo fileInfo(filename);
    if (fileInfo.isReadable())
    {
        out.Add(String("read"));
    }

    if (fileInfo.isWritable())
    {
        out.Add(String("write"));
    }

    if (fileInfo.isExecutable())
    {
        out.Add(String("execute"));
    }

    if (fileInfo.isDir())
    {
        out.Add(String("directory"));
    }

    if (fileInfo.isHidden())
    {
        out.Add(String("hidden"));
    }

    if (fileInfo.isSymLink())
    {
        out.Add(String("link"));
    }

    out.Add(String(fileInfo.owner().toStdString()));

    return out;
}
Beispiel #9
0
void RayCollider::_UnboundedStab(const AABBTreeNode* node, Container& box_indices)
{
	// Test the box against the ray
	Point Center, Extents;
	node->GetAABB()->GetCenter(Center);
	node->GetAABB()->GetExtents(Extents);
	if(!RayAABBOverlap(Center, Extents))	return;

	if(node->IsLeaf())
	{
		box_indices.Add(node->GetPrimitives(), node->GetNbPrimitives());
	}
	else
	{
		_UnboundedStab(node->GetPos(), box_indices);
		_UnboundedStab(node->GetNeg(), box_indices);
	}
}
Beispiel #10
0
STATUS 
UserManager::RowInsertedEventHandler( void *pRow, U32 rowCount, ShadowTable* ){

	Container			*pContainer;

	if( m_isIniting ){
		m_shouldReinit = true;
		return OK;
	}

	User	*pUser = new User( GetListenManager() );
	pUser->BuildYourselfFromPtsRow( (UserAccessTableEntry *)pRow );
	pUser->BuildYourValueSet();
	pUser->m_pUserManager = this;

	pContainer = new SList;
	pContainer->Add( ( CONTAINER_ELEMENT )pUser );
	AddObjectsIntoManagedObjectsVector( *pContainer );
	delete pContainer;

	SetIsReadyToServiceRequests( true );
	return OK;
}
void 
StorageElementArray::ReportYourUnderlyingDevices( Container &devices ){

	SList			tempContainer;
	StorageElement	*pElement;
	U32				index;
	DesignatorId	*pId;

	devices.RemoveAll();

	for( index = 0 ; index < GetChildCount(); index++ ){

		// request a list for every child
		pElement = (StorageElement *)GetChild( index );
		pElement->ReportYourUnderlyingDevices( tempContainer );

		// move ids into the main vector
		while( tempContainer.Count() ){
			tempContainer.GetAt( (CONTAINER_ELEMENT &)pId, 0 );
			tempContainer.RemoveAt( 0 );
			devices.Add( (CONTAINER_ELEMENT) pId );
		}
	}
}