Logo Search packages:      
Sourcecode: octplot version File versions  Download package

void OctPlotApp::fd_callback ( int  fd,
void *  y 
) [static]

Parses the input commands. Handles the get, set, and del commandsto handle. by calling the appropriate method in for the object referenced. Othe commands are passed down to the root object.to handle.

Definition at line 122 of file octplotapp.cpp.

References Root::Parse().

Referenced by Init().

{
  _DEBUG_PRINT("In fd Handler\n");
  ocpl::command command(fd);
  switch(command.id()) {
    //---------------------------------------------
    //--------------- GET -------------------------
    //---------------------------------------------
  case ocpl::get: 
    if(command.nargin()<1 || command.nargin()>2) {
      ocpl::ret_error(command,"Get: accepts 1 or 2 args");
    }
    else if(command.argin(0)->id!=ocpl::real) {
      ocpl::ret_error(command,"Get: first arg should be handle");
    }
    else if(command.nargin()>1 && command.argin(1)->id!=ocpl::str) {
      ocpl::ret_error(command,"Get: second arg should be property name");
    }
    else {
      Object* obj=
      GetObjectD(static_cast<ocpl::Handle>(command.argin(0)->real_data()[0]));
      if(obj) obj->Get(command);
      else ocpl::ret_error(command,"Get: no such handle");
    }
    break;
    //---------------------------------------------
    //--------------- SET -------------------------
    //---------------------------------------------
  case ocpl::set: 
    if(command.nargin()!=3) {
      ocpl::ret_error(command,"Set: accepts 3");
    }
    else if(command.argin(0)->id!=ocpl::real) {
      ocpl::ret_error(command,"Set: first arg should be handle");
    }
    else if(command.argin(1)->id!=ocpl::str) {
      ocpl::ret_error(command,"Set: second arg should be property name");
    }
    else {
      Object* obj=
      GetObjectD(static_cast<ocpl::Handle>(command.argin(0)->real_data()[0]));
      if(obj) {
        obj->Set(command);
        obj = obj->FindParentOfType("Figure");
        obj->Soil();
      }
      else ocpl::ret_error(command,"Set: no such handle");
    }
    break;
    //---------------------------------------------
    //--------------- DEL -------------------------
    //---------------------------------------------
  case ocpl::del: 
    if(command.nargin()!=1) {
      ocpl::ret_error(command,"Delete: accepts 1 args");
    }
    else if(command.argin(0)->id!=ocpl::real) {
      ocpl::ret_error(command,"Delete: arg should be handle");
    }
    else if(command.argin(0)->real_data()[0]==0)
    {
      // Special case -- deleting root will exit octplot
      command.init_argout(0);
      command.ret(fd);
      sleep(1); // just to make sure fd is flushed  
      exit(0);
    }
    else {
      Object* obj=
      GetObjectD(static_cast<ocpl::Handle>(command.argin(0)->real_data()[0]));
      if(obj) {
        obj->DeleteMe();
        command.init_argout(0);
      }
      else 
        ocpl::ret_error(command,"Delete: no such handle");
    }
    break;
    //---------------------------------------------
    //--------------- OTHER -----------------------
    //---------------------------------------------
  default: 
    root->Parse(command);
    break;
  }

  if(!command.parsed())
    ocpl::ret_error(command,"Unknown command");
  command.ret(fd);
}


Generated by  Doxygen 1.6.0   Back to index