panda3d.direct.DCClass

from panda3d.direct import DCClass
class DCClass

Bases: DCDeclaration

Defines a particular DistributedClass as read from an input .dc file.

Inheritance diagram

Inheritance diagram of DCClass

getDcFile() → DCFile

Returns the DCFile object that contains the class.

Return type

DCFile

getName() → str

Returns the name of this class.

getNumber() → int

Returns a unique index number associated with this class. This is defined implicitly when the .dc file(s) are read.

getNumParents() → int

Returns the number of base classes this class inherits from.

getParent(n: int) → DCClass

Returns the nth parent class this class inherits from.

Return type

DCClass

hasConstructor() → bool

Returns true if this class has a constructor method, false if it just uses the default constructor.

getConstructor() → DCField

Returns the constructor method for this class if it is defined, or NULL if the class uses the default constructor.

Return type

DCField

getNumFields() → int

Returns the number of fields defined directly in this class, ignoring inheritance.

getField(n: int) → DCField

Returns the nth field in the class. This is not necessarily the field with index n; this is the nth field defined in the class directly, ignoring inheritance.

Return type

DCField

getFieldByName(name: str) → DCField

Returns a pointer to the DCField that shares the indicated name. If the named field is not found in the current class, the parent classes will be searched, so the value returned may not actually be a field within this class. Returns NULL if there is no such field defined.

Return type

DCField

getFieldByIndex(index_number: int) → DCField

Returns a pointer to the DCField that has the indicated index number. If the numbered field is not found in the current class, the parent classes will be searched, so the value returned may not actually be a field within this class. Returns NULL if there is no such field defined.

Return type

DCField

getNumInheritedFields() → int

Returns the total number of field fields defined in this class and all ancestor classes.

getInheritedField(n: int) → DCField

Returns the nth field field in the class and all of its ancestors.

This used to be the same thing as getFieldByIndex(), back when the fields were numbered sequentially within a class’s inheritance hierarchy. Now that fields have a globally unique index number, this is no longer true.

Return type

DCField

isStruct() → bool

Returns true if the class has been identified with the “struct” keyword in the dc file, false if it was declared with “dclass”.

isBogusClass() → bool

Returns true if the class has been flagged as a bogus class. This is set for classes that are generated by the parser as placeholder for missing classes, as when reading a partial file; it should not occur in a normal valid dc file.

inheritsFromBogusClass() → bool

Returns true if this class, or any class in the inheritance heirarchy for this class, is a “bogus” class–a forward reference to an as-yet-undefined class.

startGenerate() → None

Starts the PStats timer going on the “generate” task, that is, marks the beginning of the process of generating a new object, for the purposes of timing this process.

This should balance with a corresponding call to stopGenerate().

stopGenerate() → None

Stops the PStats timer on the “generate” task. This should balance with a preceding call to startGenerate().

output(out: ostream) → None

Write a string representation of this instance to <out>.

hasClassDef() → bool

Returns true if the DCClass object has an associated Python class definition, false otherwise.

setClassDef(class_def: object) → None

Sets the class object associated with this DistributedClass. This object will be used to construct new instances of the class.

getClassDef() → object

Returns the class object that was previously associated with this DistributedClass. This will return a new reference to the object.

hasOwnerClassDef() → bool

Returns true if the DCClass object has an associated Python owner class definition, false otherwise.

setOwnerClassDef(owner_class_def: object) → None

Sets the owner class object associated with this DistributedClass. This object will be used to construct new owner instances of the class.

getOwnerClassDef() → object

Returns the owner class object that was previously associated with this DistributedClass. This will return a new reference to the object.

receiveUpdate(distobj: object, di: DatagramIterator) → None

Extracts the update message out of the packer and applies it to the indicated object by calling the appropriate method.

receiveUpdateBroadcastRequired(distobj: object, di: DatagramIterator) → None

Processes a big datagram that includes all of the “required” fields that are sent along with a normal “generate with required” message. This is all of the atomic fields that are marked “broadcast required”.

receiveUpdateBroadcastRequiredOwner(distobj: object, di: DatagramIterator) → None

Processes a big datagram that includes all of the “required” fields that are sent along with a normal “generate with required” message. This is all of the atomic fields that are marked “broadcast ownrecv”. Should be used for ‘owner-view’ objects.

receiveUpdateAllRequired(distobj: object, di: DatagramIterator) → None

Processes a big datagram that includes all of the “required” fields that are sent when an avatar is created. This is all of the atomic fields that are marked “required”, whether they are broadcast or not.

receiveUpdateOther(distobj: object, di: DatagramIterator) → None

Processes a datagram that lists some additional fields that are broadcast in one chunk.

directUpdate(distobj: object, field_name: str, datagram: Datagram) → None

Processes an update for a named field from a packed datagram.

directUpdate(distobj: object, field_name: str, value_blob: bytes) → None

Processes an update for a named field from a packed value blob.

packRequiredField(packer: DCPacker, distobj: object, field: DCField) → bool

Looks up the current value of the indicated field by calling the appropriate get*() function, then packs that value into the packer. This field is presumably either a required field or a specified optional field, and we are building up a datagram for the generate-with-required message.

Returns true on success, false on failure.

packRequiredField(datagram: Datagram, distobj: object, field: DCField) → bool

Looks up the current value of the indicated field by calling the appropriate get*() function, then packs that value into the datagram. This field is presumably either a required field or a specified optional field, and we are building up a datagram for the generate-with-required message.

Returns true on success, false on failure.

clientFormatUpdate(field_name: str, do_id: DOID_TYPE, args: object) → Datagram

Generates a datagram containing the message necessary to send an update for the indicated distributed object from the client.

Return type

Datagram

aiFormatUpdate(field_name: str, do_id: DOID_TYPE, to_id: CHANNEL_TYPE, from_id: CHANNEL_TYPE, args: object) → Datagram

Generates a datagram containing the message necessary to send an update for the indicated distributed object from the AI.

Return type

Datagram

aiFormatUpdateMsgType(field_name: str, do_id: DOID_TYPE, to_id: CHANNEL_TYPE, from_id: CHANNEL_TYPE, msg_type: int, args: object) → Datagram

Generates a datagram containing the message necessary to send an update, using the indicated msg type for the indicated distributed object from the AI.

Return type

Datagram

aiFormatGenerate(distobj: object, do_id: DOID_TYPE, parent_id: ZONEID_TYPE, zone_id: ZONEID_TYPE, district_channel_id: CHANNEL_TYPE, from_channel_id: CHANNEL_TYPE, optional_fields: object) → Datagram
Return type

Datagram

clientFormatGenerateCMU(distobj: object, do_id: DOID_TYPE, zone_id: ZONEID_TYPE, optional_fields: object) → Datagram

Generates a datagram containing the message necessary to generate a new distributed object from the client. This requires querying the object for the initial value of its required fields.

optional_fields is a list of fieldNames to generate in addition to the normal required fields.

This method is only called by the CMU implementation.

Return type

Datagram