Empeld
Empeld plugin documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events
pluginbase.Objects.Syncable.Watchers.SyncBase< T > Class Template Reference
Inheritance diagram for pluginbase.Objects.Syncable.Watchers.SyncBase< T >:
pluginbase.Objects.Syncable.ValidatedSyncableBase< T, TBase > pluginbase.Objects.Syncable.SyncableBase< T > pluginbase.Objects.Syncable.IValidatedNetSyncable pluginbase.Objects.Syncable.INetSyncable pluginbase.Objects.Syncable.INetWatcher pluginbase.Objects.Syncable.Watchers.SmoothSync< T > pluginbase.Objects.Syncable.Watchers.Sync< T >

Public Member Functions

 SyncBase ()
 
 SyncBase (T val)
 
override string ToString ()
 
sealed override bool Equals (object obj)
 
sealed override int GetHashCode ()
 

Static Public Member Functions

static implicit operator T (SyncBase< T > sync)
 
static bool operator== (SyncBase< T > left, T right)
 
static bool operator!= (SyncBase< T > left, T right)
 
static bool operator== (SyncBase< T > left, SyncBase< T > right)
 
static bool operator!= (SyncBase< T > left, SyncBase< T > right)
 

Protected Member Functions

override void EncodeTo (BinaryWriter writer, EncodeContext context)
 Encode changes to binary data More...
 
override void DecodeFrom (BinaryReader reader, DecodeContext context)
 Decode changes from binary data More...
 
override void Persist (IPersistObject obj)
 Persist the instance to a persist object More...
 
override void Load (IReadPersistObject obj)
 Load the instance from a persist object More...
 
- Protected Member Functions inherited from pluginbase.Objects.Syncable.ValidatedSyncableBase< T, TBase >
bool Validate (T current, T proposed, DecodeContext context)
 Validate the specified current, proposed and context. More...
 
- Protected Member Functions inherited from pluginbase.Objects.Syncable.SyncableBase< T >
void Touch ()
 Touch the instance, notifying something has changed More...
 
virtual void TouchRecurse ()
 Touch the instance More...
 
virtual void ResetWatch ()
 Reset the touched state More...
 
virtual void OnChanged ()
 Raises the changed event. More...
 

Protected Attributes

InternalValue
 

Static Protected Attributes

static readonly
IEqualityComparer< T > 
Comparer
 
static readonly string TypeName
 

Additional Inherited Members

- Properties inherited from pluginbase.Objects.Syncable.INetSyncable
INetWatcher Watcher [get, set]
 Who is watching (who to inform of a change) More...
 
bool Modified [get]
 Gets a value indicating whether this pluginbase.Objects.Syncable.INetSyncable is modified. More...
 
- Events inherited from pluginbase.Objects.Syncable.SyncableBase< T >
Action< T > Changed
 Event triggered when any change occurs on this object, either locally or over the network More...
 
Action< T > NetUpdate
 Event triggered when a change occurs resulting from a change over the network More...
 
Action< T > Touched
 Event occurs only when an object is first touched. Usually the first instance of a local-change More...
 

Constructor & Destructor Documentation

pluginbase.Objects.Syncable.Watchers.SyncBase< T >.SyncBase ( )
53  {
54 
55  }
pluginbase.Objects.Syncable.Watchers.SyncBase< T >.SyncBase ( val)
58  {
59  //Set _value using a default init val; Because it's during init, we don't need to touch()
60  InternalValue = val;
61  }

Member Function Documentation

override void pluginbase.Objects.Syncable.Watchers.SyncBase< T >.DecodeFrom ( BinaryReader  reader,
DecodeContext  context 
)
protectedvirtual

Decode changes from binary data

Parameters
readerReader.
contextContext.

Implements pluginbase.Objects.Syncable.SyncableBase< T >.

74  {
75  bool isDefault = reader.ReadBoolean();
76  T newVal = default(T);
77  if (!isDefault)
78  newVal = (T)_codec.Decode(reader);
79 
80  if (!context.ValidateValue || this.Validate(this.InternalValue, newVal, context))
81  {
82  this.InternalValue = newVal;
83  }
84  else
85  {
86  context.Fail();
87  }
88  }
BinaryDecoder Decode
Definition: TypeCodec.cs:15
override void pluginbase.Objects.Syncable.Watchers.SyncBase< T >.EncodeTo ( BinaryWriter  writer,
EncodeContext  context 
)
protectedvirtual

Encode changes to binary data

Parameters
writerWriter.
contextContext.

Implements pluginbase.Objects.Syncable.SyncableBase< T >.

66  {
67  bool isDefault = this.IsDefault;
68  writer.Write(isDefault);
69  if (!isDefault)
70  _codec.Encode(writer, InternalValue);
71  }
BinaryEncoder Encode
Definition: TypeCodec.cs:14
sealed override bool pluginbase.Objects.Syncable.Watchers.SyncBase< T >.Equals ( object  obj)
114  {
115  if (obj is T)
116  return Comparer.Equals(InternalValue, (T)obj);
117  if (obj is SyncBase<T>)
118  return Comparer.Equals(InternalValue, ((SyncBase<T>)obj).InternalValue);
119  return false;
120  }
static readonly IEqualityComparer< T > Comparer
Definition: SyncBase.cs:13
sealed override int pluginbase.Objects.Syncable.Watchers.SyncBase< T >.GetHashCode ( )
148  {
149  return InternalValue.GetHashCode();
150  }
override void pluginbase.Objects.Syncable.Watchers.SyncBase< T >.Load ( IReadPersistObject  obj)
protectedvirtual

Load the instance from a persist object

Parameters
objObject.

Implements pluginbase.Objects.Syncable.SyncableBase< T >.

97  {
98  if (obj.Has())
99  InternalValue = obj.Get<T>();
100  else
101  InternalValue = default(T);
102  }
static implicit pluginbase.Objects.Syncable.Watchers.SyncBase< T >.operator T ( SyncBase< T >  sync)
static
123  {
124  return sync.InternalValue;
125  }
static bool pluginbase.Objects.Syncable.Watchers.SyncBase< T >.operator!= ( SyncBase< T >  left,
right 
)
static
133  {
134  return !Comparer.Equals(left.InternalValue, right);
135  }
static readonly IEqualityComparer< T > Comparer
Definition: SyncBase.cs:13
static bool pluginbase.Objects.Syncable.Watchers.SyncBase< T >.operator!= ( SyncBase< T >  left,
SyncBase< T >  right 
)
static
143  {
144  return !Comparer.Equals(left.InternalValue, right.InternalValue);
145  }
static readonly IEqualityComparer< T > Comparer
Definition: SyncBase.cs:13
static bool pluginbase.Objects.Syncable.Watchers.SyncBase< T >.operator== ( SyncBase< T >  left,
right 
)
static
128  {
129  return Comparer.Equals(left.InternalValue, right);
130  }
static readonly IEqualityComparer< T > Comparer
Definition: SyncBase.cs:13
static bool pluginbase.Objects.Syncable.Watchers.SyncBase< T >.operator== ( SyncBase< T >  left,
SyncBase< T >  right 
)
static
138  {
139  return Comparer.Equals(left.InternalValue, right.InternalValue);
140  }
static readonly IEqualityComparer< T > Comparer
Definition: SyncBase.cs:13
override void pluginbase.Objects.Syncable.Watchers.SyncBase< T >.Persist ( IPersistObject  obj)
protectedvirtual

Persist the instance to a persist object

Parameters
objObject.

Implements pluginbase.Objects.Syncable.SyncableBase< T >.

91  {
92  if (!this.IsDefault)
93  obj.Set(InternalValue);
94  }
override string pluginbase.Objects.Syncable.Watchers.SyncBase< T >.ToString ( )
109  {
110  return string.Format("[Sync<{0}>: {1}]", TypeName, InternalValue);
111  }
static readonly string TypeName
Definition: SyncBase.cs:14

Member Data Documentation

readonly IEqualityComparer<T> pluginbase.Objects.Syncable.Watchers.SyncBase< T >.Comparer
staticprotected
T pluginbase.Objects.Syncable.Watchers.SyncBase< T >.InternalValue
protected
readonly string pluginbase.Objects.Syncable.Watchers.SyncBase< T >.TypeName
staticprotected

The documentation for this class was generated from the following file: