++ed by:

1 non-PAUSE user(s).

Steffen Müller

NAME

ZMQ::Declare::ZDCF - Object representing ZeroMQ Device Configuration (File)

SYNOPSIS

  use ZMQ::Declare;
  
  my $zdcf = ZMQ::Declare::ZDCF->new(tree => $json_zdcf_filename);
  # Alternatively
  my $zdcf = ZMQ::Declare::ZDCF->new(
    encoder => ZMQ::Declare::ZDCF::Encoder::YourFormat->new,
    tree => $zdcf_file_with_different_encoding
  );
  
  my $app = $zdcf->application("event_broker");
  # ...

DESCRIPTION

This class represents the content of a single ZDCF. That means, it covers a single 0MQ threading context and an arbitrary number of devices and sockets.

METHODS

new

Constructor taking named arguments. Any parameters listed under METHOD-ACCESSIBLE INSTANCE PROPERTIES can be supplied, but a tree is the main input and thus required.

You can provide the tree property as any one of the following:

  • A hash reference that represents the underlying ZDCF data structure. It will be validated using the ZDCF validator but otherwise won't be touched (or cloned).

  • A reference to a scalar. The scalar is assumed to contain valid input for the decoder (by default: JSON-encoded ZDCF). The thusly decoded Perl data structure will be validated like if you provided a hash reference.

  • A string, which is interpreted as a file name to read from. The data read from the file will be decoded and validated as per the above.

application

Given an application name, creates a ZMQ::Declare::Application object from the information stored in the ZDCF tree and returns that object.

This ZMQ::Declare::Application object contains one 0MQ threading context and one or many 0MQ device objects. Those devise are what you can use to actually implement 0MQ devices that are configured through ZDCF. Note that creating a ZMQ::Declare::Application object does not create any 0MQ contexts, sockets, or connections yet.

application_names

Returns a list (not a reference) of application names that are known to the ZDCF tree.

encode

Encodes the ZDCF data structure using the object's encoder and returns a scalar reference to the result.

write_to_file

Writes the ZDCF content to the given file name.

SEE ALSO

The ZDCF RFC http://rfc.zeromq.org/spec:5

ZMQ::Declare, ZMQ::Declare::Application, ZMQ::Declare::Device

ZeroMQ

METHOD-ACCESSIBLE INSTANCE PROPERTIES

validator

Get/set the validator object that can check a Perl-datastructure ZDCF tree for structural correctness. Must be a ZMQ::Declare::ZDCF::Validator object or an object of a derived class. Defaults to a new ZMQ::Declare::ZDCF::Validator object.

encoder

Get/set the encoder (decoder) object for turning a text file into a ZDCF tree in memory and vice versa. Needs to be an object of a class derived from ZMQ::Declare::ZDCF::Encoder. Defaults to a ZMQ::Declare::ZDCF::Encoder::JSON object for reading/writing JSON-encoded ZDCF.

tree

The actual nested (and untyped) Perl data structure that represents the ZDCF information. See the documentation for the constructor for details on what data is valid to supply to the constructor for this property.

AUTHOR

Steffen Mueller <smueller@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2012 by Steffen Mueller

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.1 or, at your option, any later version of Perl 5 you may have available.