HCE Project PHP language client API bindings OOP style  1.1.1
Hierarchical Cluster Engine PHP Client Interface API OOP style
 All Classes Namespaces Files Functions Variables Pages
NodeCommand.inc.php
Go to the documentation of this file.
1 <?php
2 
14 namespace HCE\admin {
15 
16  require_once __DIR__ . '/../transport/Constants.inc.php';
21  class NodeCommand {
25  protected $handlerName =\HCE\transport\HANDLER_ADMIN;
26 
30  protected $commandName = CMD_ECHO;
31 
35  protected $commandParameters = array ();
36 
40  protected $error = 0;
41 
49  public function setHandlerName($handlerName) {
50  $this->handlerName = $handlerName;
51  }
52 
58  public function getHandlerName() {
59  return $this->handlerName;
60  }
61 
69  public function setCommandName($commandName) {
70  $this->commandName = $commandName;
71  }
72 
78  public function getCommandName() {
79  return $this->commandName;
80  }
81 
90  public function setCommandParameters($commandParameters) {
91  if (is_array ( $commandParameters )) {
92  $this->commandParameters = $commandParameters;
93  return true;
94  } else {
95  return false;
96  }
97  }
98 
104  public function getCommandParameters() {
105  return $this->commandParameters;
106  }
107 
113  public function getParametersData($delimiter = CMD_PARAMETERS_DELIMITER) {
114  return implode ( $delimiter, $this->getCommandParameters () );
115  }
116 
122  public function getMessageBody($delimiter = CMD_PARAMETERS_DELIMITER) {
123  return $this->getHandlerName () . CMD_DELIMITER . $this->getCommandName () . CMD_DELIMITER . $this->getParametersData() . CMD_DELIMITER;
124  }
125 
133  public function setErrorCode($errorCode) {
134  $this->error = $errorCode;
135  }
136 
142  public function getErrorCode() {
143  return $this->error;
144  }
145 
156  public function __construct($commandName = null, $commandParameters = null, $handlerName = null) {
157  // Set command name
158  if ($commandName !== null) {
159  $this->setCommandName ( $commandName );
160  }
161  // Set command parameters
162  if ($commandParameters !== null) {
163  $this->setCommandParameters ( $commandParameters );
164  }
165  if ($handlerName !== null) {
166  $this->setHandlerName ( $handlerName );
167  }
168  }
169 
173  public function __destruct() {
174  $this->commandParameters = null;
175  }
176  }
177 }
178 
179 ?>