001/*
002 * $Id$
003 */
004
005package edu.jas.gb;
006
007
008import java.io.Serializable;
009
010import edu.jas.poly.GenPolynomial;
011import edu.jas.structure.RingElem;
012
013
014/**
015 * Distributed GB transport message. This class and its subclasses are used for
016 * transport of polynomials and pairs and as markers in distributed GB
017 * algorithms.
018 * @author Heinz Kredel
019 */
020
021public class GBTransportMess implements Serializable {
022
023
024    public GBTransportMess() {
025    }
026
027
028    /**
029     * toString.
030     */
031    @Override
032    public String toString() {
033        return this.getClass().getName();
034    }
035}
036
037
038/**
039 * Distributed GB transport message for requests.
040 */
041
042final class GBTransportMessReq extends GBTransportMess {
043
044
045    public GBTransportMessReq() {
046    }
047}
048
049
050/**
051 * Distributed GB transport message for termination.
052 */
053
054final class GBTransportMessEnd extends GBTransportMess {
055
056
057    public GBTransportMessEnd() {
058    }
059}
060
061
062/**
063 * Distributed GB transport message for polynomial.
064 */
065
066final class GBTransportMessPoly<C extends RingElem<C>> extends GBTransportMess {
067
068
069    /**
070     * The polynomial to transport.
071     */
072    public final GenPolynomial<C> pol;
073
074
075    /**
076     * GBTransportMessPoly.
077     * @param p polynomial to transferred.
078     */
079    public GBTransportMessPoly(GenPolynomial<C> p) {
080        this.pol = p;
081    }
082
083
084    /**
085     * toString.
086     */
087    @Override
088    public String toString() {
089        return super.toString() + "( " + pol + " )";
090    }
091}
092
093
094/**
095 * Distributed GB transport message for pairs.
096 */
097
098final class GBTransportMessPair<C extends RingElem<C>> extends GBTransportMess {
099
100
101    public final Pair<C> pair;
102
103
104    /**
105     * GBTransportMessPair.
106     * @param p pair for transfer.
107     */
108    public GBTransportMessPair(Pair<C> p) {
109        this.pair = p;
110    }
111
112
113    /**
114     * toString.
115     */
116    @Override
117    public String toString() {
118        return super.toString() + "( " + pair + " )";
119    }
120}
121
122
123/**
124 * Distributed GB transport message for index pairs.
125 */
126
127final class GBTransportMessPairIndex extends GBTransportMess {
128
129
130    public final int i;
131
132
133    public final int j;
134
135
136    public final int s;
137
138
139    /**
140     * GBTransportMessPairIndex.
141     * @param p pair for transport.
142     */
143    public GBTransportMessPairIndex(Pair p) {
144        this(p.i, p.j, p.s);
145    }
146
147
148    /**
149     * GBTransportMessPairIndex.
150     * @param i first index.
151     * @param j second index.
152     * @param s maximal index.
153     */
154    public GBTransportMessPairIndex(int i, int j, int s) {
155        this.i = i;
156        this.j = j;
157        s = Math.max(this.i, s);
158        s = Math.max(this.j, s);
159        this.s = s;
160    }
161
162
163    /**
164     * GBTransportMessPairIndex.
165     * @param i first index.
166     * @param j second index.
167     * @param s maximal index.
168     */
169    public GBTransportMessPairIndex(Integer i, Integer j, Integer s) {
170        this(i.intValue(), j.intValue(), s.intValue());
171    }
172
173
174    /**
175     * toString.
176     */
177    @Override
178    public String toString() {
179        return super.toString() + "(" + i + "," + j + "," + s + ")";
180    }
181
182}