24 g_typeCopy(source._getter()),
25 g_typeSource(std::move(source))
31 return &this->g_typeSource;
36 if (pck >> this->g_typeCopy)
38 this->g_typeSource._setter(this->g_typeCopy);
39 this->setLastUpdateTime();
40 this->clearWaitingUpdateFlag();
41 this->_onApplied.call();
49 auto it = this->_g_tableId.find(
id);
50 if (it != this->_g_tableId.end())
52 pck << this->g_typeSource._getter();
53 it->second._config &= ~fge::net::PerClientConfigs::CLIENTCONFIG_MODIFIED_FLAG;
59 pck << this->g_typeSource._getter();
64 return (this->g_typeSource._getter() != this->g_typeCopy) || this->_g_force;
69 this->_g_force =
true;
74 this->_g_force =
false;
75 this->g_typeCopy = this->g_typeSource._getter();
90 return this->g_typeSource;
96 pck >> this->g_typeSource->template setType<T>();
98 this->setLastUpdateTime();
99 this->clearWaitingUpdateFlag();
100 this->_onApplied.call();
106 auto it = this->_g_tableId.find(
id);
107 if (it != this->_g_tableId.end())
109 pck << this->g_typeSource->template setType<T>();
111 it->second._config &= ~fge::net::PerClientConfigs::CLIENTCONFIG_MODIFIED_FLAG;
117 pck << this->g_typeSource->template setType<T>();
123 return this->g_typeSource->isModified();
128 this->g_typeSource->setModifiedFlag(
true);
133 this->g_typeSource->setModifiedFlag(
false);
139 g_typeSource(source),
143 property.setType<T>();
149 return this->g_typeSource;
155 fge::Property&
property = this->g_typeSource->getProperty(this->g_vname);
157 pck >>
property.setType<T>();
159 this->setLastUpdateTime();
160 this->clearWaitingUpdateFlag();
161 this->_onApplied.call();
167 auto it = this->_g_tableId.find(
id);
168 if (it != this->_g_tableId.end())
170 fge::Property&
property = this->g_typeSource->getProperty(this->g_vname);
172 pck <<
property.setType<T>();
174 it->second._config &= ~fge::net::PerClientConfigs::CLIENTCONFIG_MODIFIED_FLAG;
180 fge::Property&
property = this->g_typeSource->getProperty(this->g_vname);
182 pck <<
property.setType<T>();
188 return this->g_typeSource->getProperty(this->g_vname).isModified();
193 this->g_typeSource->getProperty(this->g_vname).setModifiedFlag(
true);
198 this->g_typeSource->getProperty(this->g_vname).setModifiedFlag(
false);
204 return this->g_vname;
210 g_typeSource(source),
217 return this->g_typeSource;
223 if (pck >> *this->g_typeSource)
225 this->setLastUpdateTime();
226 this->clearWaitingUpdateFlag();
227 this->_onApplied.call();
235 fge::net::NetworkPerClientModificationTable::iterator it = this->_g_tableId.find(
id);
236 if (it != this->_g_tableId.end())
238 pck << *this->g_typeSource;
239 it->second._config &= ~fge::net::PerClientConfigs::CLIENTCONFIG_MODIFIED_FLAG;
245 pck << *this->g_typeSource;
251 return this->g_trigger;
256 this->g_trigger =
true;
261 this->g_trigger =
false;
267 this->g_trigger =
true;
273typename RecordedVector<T>::const_reference RecordedVector<T>::at(SizeType index)
const
275 return this->g_container.at(index);
278typename RecordedVector<T>::const_reference RecordedVector<T>::operator[](SizeType index)
const
280 return this->g_container[index];
283typename RecordedVector<T>::const_reference RecordedVector<T>::front()
const
285 return this->g_container.front();
288typename RecordedVector<T>::const_reference RecordedVector<T>::back()
const
290 return this->g_container.back();
293T
const* RecordedVector<T>::data()
const
295 return this->g_container.data();
299typename RecordedVector<T>::const_iterator RecordedVector<T>::begin()
const
301 return this->g_container.begin();
304typename RecordedVector<T>::const_iterator RecordedVector<T>::end()
const
306 return this->g_container.end();
309typename RecordedVector<T>::const_iterator RecordedVector<T>::cbegin()
const
311 return this->g_container.cbegin();
314typename RecordedVector<T>::const_iterator RecordedVector<T>::cend()
const
316 return this->g_container.cend();
319typename RecordedVector<T>::const_reverse_iterator RecordedVector<T>::rbegin()
const
321 return this->g_container.rbegin();
324typename RecordedVector<T>::const_reverse_iterator RecordedVector<T>::rend()
const
326 return this->g_container.rend();
329typename RecordedVector<T>::const_reverse_iterator RecordedVector<T>::crbegin()
const
331 return this->g_container.crbegin();
334typename RecordedVector<T>::const_reverse_iterator RecordedVector<T>::crend()
const
336 return this->g_container.crend();
340SizeType RecordedVector<T>::size()
const
342 return static_cast<SizeType
>(this->g_container.size());
345bool RecordedVector<T>::empty()
const
347 return this->g_container.empty();
351void RecordedVector<T>::reserve(SizeType n)
353 this->g_container.reserve(n);
357void RecordedVector<T>::clear()
359 this->g_container.clear();
361 this->pushEvent({RecordedEventTypes::REMOVE_ALL, 0});
364typename RecordedVector<T>::iterator RecordedVector<T>::insert(const_iterator pos, T
const& value)
366 SizeType index = pos - this->g_container.begin();
367 this->pushEvent({RecordedEventTypes::ADD, index});
368 return this->g_container.insert(pos, value);
371typename RecordedVector<T>::iterator RecordedVector<T>::insert(const_iterator pos, T&& value)
373 SizeType index = pos - this->g_container.begin();
374 this->pushEvent({RecordedEventTypes::ADD, index});
375 return this->g_container.insert(pos, std::move(value));
378template<
class... TArgs>
379typename RecordedVector<T>::iterator RecordedVector<T>::emplace(const_iterator pos, TArgs&&... value)
381 SizeType index = pos - this->g_container.begin();
382 this->pushEvent({RecordedEventTypes::ADD, index});
383 return this->g_container.emplace(pos, std::forward<TArgs>(value)...);
387void RecordedVector<T>::push_back(TArg&& arg)
389 this->pushEvent({RecordedEventTypes::ADD, this->g_container.size()});
390 this->g_container.push_back(std::forward<TArg>(arg));
393template<
class... TArgs>
394typename RecordedVector<T>::reference RecordedVector<T>::emplace_back(TArgs&&... arg)
396 this->pushEvent({RecordedEventTypes::ADD, this->g_container.size()});
397 return this->g_container.emplace_back(std::forward<TArgs>(arg)...);
400typename RecordedVector<T>::const_iterator RecordedVector<T>::erase(const_iterator pos)
402 SizeType index = pos - this->g_container.begin();
403 this->pushEvent({RecordedEventTypes::REMOVE, index});
404 return this->g_container.erase(pos);
407void RecordedVector<T>::pop_back()
409 this->pushEvent({RecordedEventTypes::REMOVE, this->g_container.size() - 1});
410 this->g_container.pop_back();
414typename RecordedVector<T>::reference RecordedVector<T>::modify(SizeType index)
416 this->pushEvent({RecordedEventTypes::MODIFY, index});
417 return this->g_container[index];
420typename RecordedVector<T>::reference RecordedVector<T>::modify(const_iterator pos)
422 SizeType index = pos - this->g_container.begin();
423 this->pushEvent({RecordedEventTypes::MODIFY, index});
424 return this->g_container[index];
428void RecordedVector<T>::clearEvents()
430 this->g_events.clear();
433SizeType RecordedVector<T>::eventsSize()
const
435 return static_cast<SizeType
>(this->g_events.size());
438typename RecordedVector<T>::EventQueue
const& RecordedVector<T>::getEventQueue()
const
440 return this->g_events;
444bool RecordedVector<T>::isRegisteringEvents()
const
446 return this->g_registerEvents;
449void RecordedVector<T>::registerEvents(
bool enable)
452 this->g_registerEvents = enable;
456void RecordedVector<T>::pushEvent(RecordedEvent event)
458 if (this->g_registerEvents)
460 this->g_events.emplace_back(event);
465Packet& operator<<(Packet& pck, RecordedVector<T>
const& vec)
467 return pck << vec.g_container;
470Packet
const& operator>>(Packet
const& pck, RecordedVector<T>& vec)
472 return pck >> vec.g_container;
474inline Packet& operator<<(Packet& pck, RecordedEvent
const& event)
476 return pck <<
event._type <<
event._index;
478inline Packet
const& operator>>(Packet
const& pck, RecordedEvent& event)
480 return pck >>
event._type >>
event._index;
492 for (
auto& it: this->_g_tableId)
494 this->destroyClientCustomData(it.second._customData);
501 return this->g_typeSource;
510 if (packType == PackTypes::FULL)
512 pck >> *this->g_typeSource;
516 SizeType eventCount{0};
518 for (SizeType i = 0; i < eventCount; ++i)
524 case RecordedEventTypes::ADD:
525 if (event._index >= this->g_typeSource->size())
529 this->g_typeSource->emplace_back(std::move(value));
535 this->g_typeSource->emplace(this->g_typeSource->begin() + event._index, std::move(value));
538 case RecordedEventTypes::REMOVE:
539 if (event._index < this->g_typeSource->size())
541 this->g_typeSource->erase(this->g_typeSource->begin() + event._index);
548 case RecordedEventTypes::REMOVE_ALL:
549 this->g_typeSource->clear();
551 case RecordedEventTypes::MODIFY:
552 if (event._index < this->g_typeSource->size())
554 pck >> this->g_typeSource->modify(event._index);
565 this->setLastUpdateTime();
566 this->clearWaitingUpdateFlag();
567 this->_onApplied.call();
573 auto itId = this->_g_tableId.find(
id);
574 if (itId != this->_g_tableId.end())
576 auto* events =
static_cast<typename RecordedVector<T>::EventQueue*
>(itId->second._customData);
580 pck << PackTypes::FULL;
581 pck << *this->g_typeSource;
585 pck << PackTypes::PARTIAL;
586 pck << static_cast<SizeType>(events->size());
587 for (
auto itEvent = events->begin(); itEvent != events->end(); ++itEvent)
590 if (itEvent->_type == RecordedEventTypes::ADD || itEvent->_type == RecordedEventTypes::MODIFY)
594 auto finalIndex = itEvent->_index;
595 for (
auto itReverse = events->rbegin(); &(*itReverse) != &(*itEvent); ++itReverse)
597 if (itReverse->_type == RecordedEventTypes::ADD && itReverse->_index <= finalIndex)
601 else if (itReverse->_type == RecordedEventTypes::REMOVE && itReverse->_index < finalIndex)
606 pck << this->g_typeSource->at(finalIndex);
612 itId->second._config &= ~fge::net::PerClientConfigs::CLIENTCONFIG_MODIFIED_FLAG;
618 pck << PackTypes::FULL << *this->g_typeSource;
624 auto it = this->_g_tableId.find(
id);
625 if (it != this->_g_tableId.end())
627 it->second._config |= fge::net::PerClientConfigs::CLIENTCONFIG_MODIFIED_FLAG;
628 auto* events =
static_cast<typename RecordedVector<T>::EventQueue*
>(it->second._customData);
635 auto it = this->_g_tableId.find(
id);
636 if (it != this->_g_tableId.end())
638 it->second._config &= ~fge::net::PerClientConfigs::CLIENTCONFIG_MODIFIED_FLAG;
639 auto* events =
static_cast<typename RecordedVector<T>::EventQueue*
>(it->second._customData);
649 this->g_typeSource->clearEvents();
651 return this->g_typeSource->eventsSize() != 0 || this->_g_force;
656 this->_g_force =
true;
661 this->_g_force =
false;
662 this->g_typeSource->clearEvents();
668 ptr =
new typename RecordedVector<T>::EventQueue();
671void NetworkTypeVector<T>::destroyClientCustomData(
void*& ptr)
const
673 delete static_cast<typename RecordedVector<T>::EventQueue*
>(ptr);
676void NetworkTypeVector<T>::applyClientCustomData(
void*& ptr)
const
678 auto* events =
static_cast<typename RecordedVector<T>::EventQueue*
>(ptr);
679 bool clearFirst = this->g_typeSource->getEventQueue().front()._type == RecordedEventTypes::REMOVE_ALL;
684 for (
auto const& event: this->g_typeSource->getEventQueue())
686 events->push_back(event);
A class that map a string to a Property.
Definition C_propertyList.hpp:35
A class that can store any type of data.
Definition C_property.hpp:54
The network type for a trivial type but triggered manually.
Definition C_networkType.hpp:425
void const * getSource() const override
Get the source pointer that have been used to create this network type.
Definition C_networkType.inl:215
void forceCheck() override
Force the value to be modified (even if it is not)
Definition C_networkType.inl:254
void packData(fge::net::Packet &pck, fge::net::Identity const &id) override
Pack the data into a packet and reset the modification flag of the identity.
Definition C_networkType.inl:233
void forceUncheck() override
Remove the forced modification of the value.
Definition C_networkType.inl:259
NetworkTypeManual(T *source)
NetworkTypeManual.
Definition C_networkType.inl:209
bool applyData(fge::net::Packet const &pck) override
Apply the data packed by the same network type from a server.
Definition C_networkType.inl:221
bool check() const override
Check if the value have been modified.
Definition C_networkType.inl:249
The network type for a property inside a list.
Definition C_networkType.hpp:394
void const * getSource() const override
Get the source pointer that have been used to create this network type.
Definition C_networkType.inl:147
bool check() const override
Check if the value have been modified.
Definition C_networkType.inl:186
void forceUncheck() override
Remove the forced modification of the value.
Definition C_networkType.inl:196
NetworkTypePropertyList(fge::PropertyList *source, std::string const &vname)
NetworkTypePropertyList.
Definition C_networkType.inl:138
bool applyData(fge::net::Packet const &pck) override
Apply the data packed by the same network type from a server.
Definition C_networkType.inl:153
void forceCheck() override
Force the value to be modified (even if it is not)
Definition C_networkType.inl:191
void packData(fge::net::Packet &pck, fge::net::Identity const &id) override
Pack the data into a packet and reset the modification flag of the identity.
Definition C_networkType.inl:165
void forceUncheck() override
Remove the forced modification of the value.
Definition C_networkType.inl:131
void forceCheck() override
Force the value to be modified (even if it is not)
Definition C_networkType.inl:126
bool applyData(fge::net::Packet const &pck) override
Apply the data packed by the same network type from a server.
Definition C_networkType.inl:94
void packData(fge::net::Packet &pck, fge::net::Identity const &id) override
Pack the data into a packet and reset the modification flag of the identity.
Definition C_networkType.inl:104
void const * getSource() const override
Get the source pointer that have been used to create this network type.
Definition C_networkType.inl:88
bool check() const override
Check if the value have been modified.
Definition C_networkType.inl:121
NetworkTypeProperty(fge::Property *source)
NetworkTypeProperty.
Definition C_networkType.inl:81
The network type for a vector.
Definition C_networkType.hpp:549
void forceCheck() override
Force the value to be modified (even if it is not)
Definition C_networkType.inl:654
void forceUncheckClient(fge::net::Identity const &id) override
Reset the modification flag for the specified client identity.
Definition C_networkType.inl:633
void forceUncheck() override
Remove the forced modification of the value.
Definition C_networkType.inl:659
void const * getSource() const override
Get the source pointer that have been used to create this network type.
Definition C_networkType.inl:499
bool applyData(fge::net::Packet const &pck) override
Apply the data packed by the same network type from a server.
Definition C_networkType.inl:505
NetworkTypeVector(RecordedVector< T > *source)
NetworkTypeVector.
Definition C_networkType.inl:486
void packData(fge::net::Packet &pck, fge::net::Identity const &id) override
Pack the data into a packet and reset the modification flag of the identity.
Definition C_networkType.inl:571
bool check() const override
Check if the value have been modified.
Definition C_networkType.inl:645
void forceCheckClient(fge::net::Identity const &id) override
Force the modification flag to be set for the specified client identity.
Definition C_networkType.inl:622
NetworkType(fge::DataAccessor< T > source)
NetworkType.
Definition C_networkType.inl:23
void forceCheck() override
Force the value to be modified (even if it is not)
Definition C_networkType.inl:67
void packData(fge::net::Packet &pck, fge::net::Identity const &id) override
Pack the data into a packet and reset the modification flag of the identity.
Definition C_networkType.inl:47
void forceUncheck() override
Remove the forced modification of the value.
Definition C_networkType.inl:72
bool applyData(fge::net::Packet const &pck) override
Apply the data packed by the same network type from a server.
Definition C_networkType.inl:34
void const * getSource() const override
Get the source pointer that have been used to create this network type.
Definition C_networkType.inl:29
bool check() const override
Check if the value have been modified.
Definition C_networkType.inl:62
Definition C_packet.hpp:70
Definition C_networkType.hpp:473
Definition C_dataAccessor.hpp:27
A class to represent a client or server identity with an IP address and a port.
Definition C_identity.hpp:31
Definition C_networkType.hpp:463