1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
4 | *
|
---|
5 | * This file is part of HeuristicLab.
|
---|
6 | *
|
---|
7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
8 | * it under the terms of the GNU General Public License as published by
|
---|
9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
10 | * (at your option) any later version.
|
---|
11 | *
|
---|
12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | * GNU General Public License for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU General Public License
|
---|
18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
19 | */
|
---|
20 | #endregion
|
---|
21 |
|
---|
22 | using System;
|
---|
23 | using HeuristicLab.Common;
|
---|
24 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
25 |
|
---|
26 | namespace HeuristicLab.Hive.Contracts {
|
---|
27 | /// <summary>
|
---|
28 | /// The MessageContainer is a container class for Messages. Its two parts are:
|
---|
29 | /// the actual message itself and the JobId, refered by the message
|
---|
30 | /// </summary>
|
---|
31 | [StorableClass]
|
---|
32 | [Serializable]
|
---|
33 | public class MessageContainer : IDeepCloneable {
|
---|
34 |
|
---|
35 | public enum MessageType {
|
---|
36 | FetchJob, AbortJob, JobAborted, RequestSnapshot, FinishedJob, NoMessage, SnapshotReady, Shutdown, JobFailed, UptimeLimitDisconnect,
|
---|
37 | FetchOrForceFetchCalendar, AddChildJob,
|
---|
38 | PauseJob,
|
---|
39 | GetChildJobs,
|
---|
40 | DeleteChildJobs
|
---|
41 | };
|
---|
42 |
|
---|
43 | [Storable]
|
---|
44 | public MessageType Message { get; set; }
|
---|
45 | [Storable]
|
---|
46 | public Guid JobId { get; set; }
|
---|
47 |
|
---|
48 | public MessageContainer(MessageType message) {
|
---|
49 | Message = message;
|
---|
50 | JobId = Guid.Empty;
|
---|
51 | }
|
---|
52 |
|
---|
53 | public MessageContainer(MessageType message, Guid jobId) {
|
---|
54 | Message = message;
|
---|
55 | JobId = jobId;
|
---|
56 | }
|
---|
57 |
|
---|
58 | public virtual IDeepCloneable Clone(Cloner cloner) {
|
---|
59 | MessageContainer clone = (MessageContainer)Activator.CreateInstance(this.GetType(), true);
|
---|
60 | cloner.RegisterClonedObject(this, clone);
|
---|
61 | clone.Message = this.Message;
|
---|
62 | clone.JobId = this.JobId;
|
---|
63 | return clone;
|
---|
64 | }
|
---|
65 |
|
---|
66 | public object Clone() {
|
---|
67 | return Clone(new Cloner());
|
---|
68 | }
|
---|
69 | }
|
---|
70 | }
|
---|