24 package org.lightjason.agentspeak.beliefbase;
26 import com.google.common.collect.HashMultimap;
27 import com.google.common.collect.Multimap;
28 import com.google.common.collect.Multimaps;
29 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
37 import javax.annotation.Nonnull;
38 import java.lang.ref.PhantomReference;
39 import java.lang.ref.Reference;
40 import java.lang.ref.ReferenceQueue;
41 import java.util.Collections;
42 import java.util.HashSet;
43 import java.util.Objects;
45 import java.util.stream.Stream;
57 @SuppressFBWarnings(
"RI_REDUNDANT_INTERFACES" )
64 private final Multimap<IView, ITrigger> m_events = Multimaps.synchronizedSetMultimap( HashMultimap.create() );
68 private final Set<IView> m_views = Collections.synchronizedSet(
new HashSet<>() );
72 private final ReferenceQueue<IView> m_maskreference =
new ReferenceQueue<>();
79 return this.eventreference(
new CView( p_name,
this ) );
86 return this.eventreference(
new CView( p_name,
this, p_parent ) );
108 for ( Reference<? extends IView> l_reference = m_maskreference.poll(); Objects.nonNull( l_reference ); l_reference = m_maskreference.poll() )
110 final IView l_view = l_reference.get();
111 if ( Objects.nonNull( l_view ) )
114 m_events.asMap().
remove( l_view );
125 return this.cleartrigger( p_view );
138 m_views.parallelStream().forEach( i -> m_events.put( i, l_trigger ) );
151 m_events.removeAll( p_view );
163 new PhantomReference<>( p_view, m_maskreference );
164 m_views.
add( p_view );
176 return m_events.removeAll( p_view ).stream();
final IView internalremove(final IView p_view)
removes the interal view references
ILiteral event(final ITrigger.EType p_event, final ILiteral p_literal)
push an event and literal to the event map
IView remove( @Nonnull final Stream< ILiteral > p_literal)
removes a literal in the current structure
static ITrigger from( @Nonnull final EType p_event, @Nonnull final ILiteral p_literal)
creates a trigger event^
view for a beliefbase that creates any access to the underlying data structures
final Stream< ITrigger > cleartrigger(final IView p_view)
copy of all trigger values
interface of beliefbase definition, that create the trigger events for the agent
Stream< ITrigger > trigger( @Nonnull final IView p_view)
returns all trigger of the beliefbase
default behaviour of a beliefbase
final IView create( @Nonnull final String p_name)
returns a new view of the belief base
IView add( @Nonnull final ILiteral... p_literal)
adds a literal in the current structure
IAgent<?> update( @Nonnull final IAgent<?> p_agent)
updates all items
ILiteral add( @Nonnull final ILiteral p_literal)
adds a literal
IView eventreference(final IView p_view)
adds a view to the event referencing structure
final IView create( @Nonnull final String p_name, final IView p_parent)