00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef _ZOIDNODE_H_
00010 #define _ZOIDNODE_H_
00011
00015 #include "zoidcom.h"
00016
00017 class ZCom_Node_Private;
00018 class ZCom_Control;
00019 class ZCom_BitStream;
00020 class ZCom_NodeEventInterceptor;
00021 class ZCom_NodeReplicationInterceptor;
00022 class ZCom_Replicator;
00023
00024
00025
00026
00027
00032
00033 #define ZCOM_REPFLAG_NONE 0
00034
00035 #define ZCOM_REPFLAG_UNRELIABLE (1L << 0)
00036
00037 #define ZCOM_REPFLAG_MOSTRECENT (1L << 1)
00038
00047 #define ZCOM_REPFLAG_RARELYCHANGED (1L << 2)
00050 #define ZCOM_REPFLAG_ONLYONCE (1L << 3)
00051
00052 #define ZCOM_REPFLAG_INTERCEPT (1L << 4)
00053
00062 #define ZCOM_REPFLAG_SETUPPERSISTS (1L << 5)
00063
00071 #define ZCOM_REPFLAG_SETUPAUTODELETE (1L << 6)
00072
00085 #define ZCOM_REPFLAG_STARTCLEAN (1L << 7)
00086
00087
00096
00098 #define ZCOM_REPRULE_NONE 0
00099
00100 #define ZCOM_REPRULE_AUTH_2_PROXY (1L << 0)
00101
00102 #define ZCOM_REPRULE_AUTH_2_OWNER (1L << 1)
00103
00104 #define ZCOM_REPRULE_AUTH_2_ALL (ZCOM_REPRULE_AUTH_2_PROXY|ZCOM_REPRULE_AUTH_2_OWNER)
00105
00106 #define ZCOM_REPRULE_OWNER_2_AUTH (1L << 2)
00107
00108
00110
00111
00113 #define ZCOM_FTRANS_ID_BITS 32
00114
00115 #define ZCOM_FTRANS_SIZE_BITS 32
00116
00117 #define ZCOM_FTRANS_CHUNK_BITS 16
00118
00119
00143 class ZCOM_API ZCom_Node
00144 {
00145 protected:
00146 ZCom_Node_Private *m_priv;
00147
00148 public:
00149 ZCom_Node( void );
00150 ~ZCom_Node( void );
00151
00152
00153
00154
00167
00174 bool
00175 registerNodeUnique( ZCom_ClassID _classid, eZCom_NodeRole _role, ZCom_Control *_control );
00176
00188 bool
00189 registerNodeByTag( ZCom_ClassID _classid, zU32 _tag, eZCom_NodeRole _role, ZCom_Control *_control );
00190
00199 bool
00200 registerNodeDynamic( ZCom_ClassID _classid, ZCom_Control *_control );
00201
00217 bool
00218 registerRequestedNode( ZCom_ClassID _classid, ZCom_Control *_control );
00219
00231 bool
00232 unregisterNode();
00233
00240 void
00241 disconnectAll();
00242
00244
00249
00256 void
00257 setUpdatePriority( zU16 _prio );
00258
00267 void
00268 setDefaultRelevance( zFloat _default_relevance );
00269
00279 void
00280 setConnectionSpecificRelevance( ZCom_ConnID _conn, zFloat _rel );
00281
00285 zU32
00286 getRelevantConnectionCount() const;
00287
00302 zS32
00303 getRelevantConnections( ZCom_ConnID *_conns, zU32 _max, zU32 *_count ) const;
00304
00318 void
00319 dependsOn( ZCom_Node *_othernode, eZCom_DependencyOpt _opt = eZCom_AddDependency );
00320
00330 void
00331 applyForZoidLevel( zU8 _level );
00332
00340 void
00341 removeFromZoidLevel( zU8 _level );
00342
00348 zU32
00349 getZoidLevelCount( ) const;
00350
00357 zU8
00358 getZoidLevel( zU32 _index ) const;
00359
00395 void
00396 setMustSync( bool _enabled, zU16 _order );
00397
00413 void
00414 setSyncResult( ZCom_ConnID _conn, bool _success, ZCom_BitStream *_errormsg );
00415
00426 void
00427 setSyncResultAutoSuccess( bool _enabled );
00428
00458 void
00459 setOwner( ZCom_ConnID _id, bool _enabled );
00460
00467 void
00468 setPrivate( bool _enabled );
00469
00485 void
00486 setAnnounceData( ZCom_BitStream *_data );
00487
00489
00490
00491
00492
00498
00504 bool
00505 beginReplicationSetup( zU16 _replicators_max );
00506
00513 void
00514 setInterceptID( ZCom_InterceptID _id );
00515
00532 void
00533 addReplicationInt( zS32 *_ptr, zU8 _bits, bool _sign, zU8 _flags, zU8 _rules, zS16 _mindelay = -1, zS16 _maxdelay = -1 );
00534
00546 void
00547 addReplicationBool( bool *_ptr, zU8 _flags, zU8 _rules, zS16 _mindelay = -1, zS16 _maxdelay = -1 );
00548
00581 void
00582 addReplicationFloat(zFloat *_ptr, zU8 _mantissa_bits, zU8 _flags, zU8 _rules, zS16 _mindelay = -1, zS16 _maxdelay = -1);
00583
00596 void
00597 addReplicationString( char *_str, zU16 _maxlen, zU8 _flags, zU8 _rules, zS16 _mindelay = -1, zS16 _maxdelay = -1);
00598
00611 void
00612 addReplicationStringW( wchar_t *_str, zU16 _maxlen, zU8 _flags, zU8 _rules, zS16 _mindelay = -1, zS16 _maxdelay = -1);
00613
00614
00615
00616
00617
00618
00619
00620
00651 void
00652 addInterpolationInt( zS32 *_ptr, zU8 _bits, bool _sign, zU8 _flags, zU8 _rules, zS32 _treshold, zS32 *_dst = NULL,
00653 zS16 _mindelay = -1, zS16 _maxdelay = -1, zFloat _ipolfac = 0.4f );
00654
00680 void
00681 addInterpolationFloat( zFloat *_ptr, zU8 _mantissa_bits, zU8 _flags, zU8 _rules, zFloat _treshold, zFloat *_dst = NULL,
00682 zS16 _mindelay = -1, zS16 _maxdelay = -1, zFloat _ipolfac = 0.4f );
00683
00700 void
00701 addReplicator(ZCom_Replicator *_rep, bool _autodelete);
00702
00711 bool
00712 endReplicationSetup( void );
00713
00719 void
00720 setReplicationInterceptor(ZCom_NodeReplicationInterceptor *_interceptor);
00722
00723
00724
00725
00729
00736 bool
00737 sendEvent( eZCom_SendMode _mode, zU8 _rules, ZCom_BitStream *_data );
00738
00746 bool
00747 sendEventDirect( eZCom_SendMode _mode, ZCom_BitStream *_data, ZCom_ConnID _destconn );
00748
00755 bool
00756 sendEventToGroup( eZCom_SendMode _mode, ZCom_BitStream *_data, ZCom_GroupID _destgroup );
00757
00762 void
00763 setEventNotification( bool _oninit, bool _onremove );
00764
00768 bool
00769 checkEventWaiting() const;
00770
00784 ZCom_BitStream*
00785 getNextEvent( eZCom_Event* _type, eZCom_NodeRole* _remote_role, ZCom_ConnID* _connid, zU32* _estimated_time_sent = NULL );
00786
00801 ZCom_FileTransID
00802 sendFile( const char *_path, const char *_pathtosend, ZCom_ConnID _destconn, ZCom_BitStream *_data, zFloat _aggressivenes );
00803
00810 void
00811 acceptFile( ZCom_ConnID _src_id, ZCom_FileTransID _ftrans_id, const char *_path, bool _accept );
00812
00819 const ZCom_FileTransInfo&
00820 getFileInfo( ZCom_ConnID _conn_id, ZCom_FileTransID _ftrans_id ) const;
00821
00827 void
00828 setEventInterceptor(ZCom_NodeEventInterceptor *_interceptor);
00830
00831
00832
00833
00845 bool
00846 setUserData( ZCom_ConnID _conn, void *_data );
00847
00852 void*
00853 getUserData( ZCom_ConnID _conn ) const;
00854
00861 void
00862 setUserData( void *_data );
00866 void*
00867 getUserData() const;
00868
00869
00870
00879 zS32
00880 getUpdateDelta() const;
00881
00890 zU32
00891 getCurrentUpdateRate() const;
00892
00899 zS32
00900 getEstimatedTimeUntilPossibleUpdate() const;
00901
00905 ZCom_Control*
00906 getControl() const;
00907
00911 eZCom_NodeRole
00912 getRole() const;
00913
00919 bool
00920 isPrivate() const;
00921
00925 ZCom_ClassID
00926 getClassID() const;
00927
00937 ZCom_NodeID
00938 getNetworkID() const;
00939
00941 };
00942
00943 #endif