Empeld
Empeld plugin documentation.
pluginbase.Objects.Syncable.Watchers.SyncBase< T > Class Template Reference
Inheritance diagram for pluginbase.Objects.Syncable.Watchers.SyncBase< T >:
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)
 
override void DecodeFrom (BinaryReader reader, DecodeContext context)
 
override void Persist (IPersistObject obj)
 
override void Load (IReadPersistObject obj)
 

Protected Attributes

InternalValue
 

Static Protected Attributes

static readonly IEqualityComparer< T > Comparer
 
static readonly string TypeName
 

Constructor & Destructor Documentation

◆ SyncBase() [1/2]

◆ SyncBase() [2/2]

58  {
59  //Set _value using a default init val; Because it's during init, we don't need to touch()
60  InternalValue = val;
61  }
T InternalValue
Definition: SyncBase.cs:16

Member Function Documentation

◆ DecodeFrom()

override void pluginbase.Objects.Syncable.Watchers.SyncBase< T >.DecodeFrom ( BinaryReader  reader,
DecodeContext  context 
)
protected
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
T InternalValue
Definition: SyncBase.cs:16

◆ EncodeTo()

override void pluginbase.Objects.Syncable.Watchers.SyncBase< T >.EncodeTo ( BinaryWriter  writer,
EncodeContext  context 
)
protected
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
T InternalValue
Definition: SyncBase.cs:16

◆ Equals()

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
T InternalValue
Definition: SyncBase.cs:16

◆ GetHashCode()

sealed override int pluginbase.Objects.Syncable.Watchers.SyncBase< T >.GetHashCode ( )
148  {
149  return InternalValue.GetHashCode();
150  }
T InternalValue
Definition: SyncBase.cs:16

◆ Load()

override void pluginbase.Objects.Syncable.Watchers.SyncBase< T >.Load ( IReadPersistObject  obj)
protected
97  {
98  if (obj.Has())
99  InternalValue = obj.Get<T>();
100  else
101  InternalValue = default(T);
102  }
T InternalValue
Definition: SyncBase.cs:16

◆ operator T()

static implicit pluginbase.Objects.Syncable.Watchers.SyncBase< T >.operator T ( SyncBase< T >  sync)
static
123  {
124  return sync.InternalValue;
125  }

◆ operator!=() [1/2]

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

◆ operator!=() [2/2]

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

◆ operator==() [1/2]

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

◆ operator==() [2/2]

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

◆ Persist()

override void pluginbase.Objects.Syncable.Watchers.SyncBase< T >.Persist ( IPersistObject  obj)
protected
91  {
92  if (!this.IsDefault)
93  obj.Set(InternalValue);
94  }
T InternalValue
Definition: SyncBase.cs:16

◆ ToString()

override string pluginbase.Objects.Syncable.Watchers.SyncBase< T >.ToString ( )
109  {
110  return string.Format("[Sync<{0}>: {1}]", TypeName, InternalValue);
111  }
T InternalValue
Definition: SyncBase.cs:16
static readonly string TypeName
Definition: SyncBase.cs:14

Member Data Documentation

◆ Comparer

readonly IEqualityComparer<T> pluginbase.Objects.Syncable.Watchers.SyncBase< T >.Comparer
staticprotected

◆ InternalValue

T pluginbase.Objects.Syncable.Watchers.SyncBase< T >.InternalValue
protected

◆ TypeName

readonly string pluginbase.Objects.Syncable.Watchers.SyncBase< T >.TypeName
staticprotected

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