All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jclarion.clarion.runtime.ManyGlue Maven / Gradle / Ivy

The newest version!
/**
 * Copyright 2010, by Andrew Barnham
 *
 * The contents of this file are subject to
 * GNU Lesser General Public License (LGPL), v.3
 * http://www.gnu.org/licenses/lgpl.txt
 * 
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied.
 */
package org.jclarion.clarion.runtime;

import java.util.ArrayList;
import java.util.List;

import org.jclarion.clarion.ClarionMemoryChangeListener;
import org.jclarion.clarion.ClarionMemoryModel;
import org.jclarion.clarion.memory.CMem;

/** 
 * glue many memory objects together (serially) and treat them as a single object
 * 
 * @author barney
 */

public class ManyGlue extends ClarionMemoryModel
{
    private List elements;
    private ClarionMemoryChangeListener notifyChildChange;

    /*
    public static ManyGlue array(ClarionMemoryModel array[]) {
        ManyGlue result = new ManyGlue();
        for (int scan=0;scan();
        notifyChildChange=new ClarionMemoryChangeListener() {
            @Override
            public void objectChanged(ClarionMemoryModel model) {
                notifyChange();
            }
        };
    }
    
    public void add(ClarionMemoryModel model)
    {
        elements.add(model);
        model.addChangeListener(notifyChildChange);
    }
    

    @Override
    public void deserialize(CMem os) {
        for ( ClarionMemoryModel element : elements ) {
            element.deserialize(os);
        }
    }

    @Override
    public void serialize(CMem is) {
        for ( ClarionMemoryModel element : elements ) {
            element.serialize(is);
        }
    }

    @Override
    public Object getLockedObject(Thread t) {
        return this;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy