Beispiel #1
0
void CSharpWriter::writeOverridesRecursive(UMLClassifierList *superclasses, QTextStream &cs) {
    // oplist for implemented abstract operations
    UMLOperationList opabstract;
    opabstract.setAutoDelete(false);
    UMLClassifier *obj;

    for (obj = superclasses->first(); obj; obj = superclasses->next()) {
        if (!obj->isInterface() && obj->hasAbstractOps()) {
            // collect abstract ops
            UMLOperationList opl(obj->getOpList());
            for (UMLOperation *op = opl.first(); op ; op = opl.next()) {
                if (op->getAbstract()) {
                    opabstract.append(op);
                }
            }

            // write abstract implementations
            cs << m_endl << m_container_indent << m_indentation << "#region " << obj->getName() << " members" << m_endl << m_endl;
            writeOperations(opabstract,cs,false,true,true);
            cs << m_container_indent << m_indentation << "#endregion" << m_endl << m_endl;

            opabstract.clear();
        }
        // Recurse to parent superclasses
        UMLClassifierList superRecursive = obj->getSuperClasses();
        UMLClassifierList *superRecursivePtr =& superRecursive;
        if (superRecursivePtr->count() > 0) {
            writeOverridesRecursive(superRecursivePtr, cs);
        }
    }
}
Beispiel #2
0
bool LoadAdrib(const string& filename) {
  if (is_no_sound)
    return true;
  CEmuopl       opl(rate, bit16, stereo);
  CPlayer*      p = CAdPlug::factory(filename.c_str(), &opl);
  short         buf[buf_size];
  unsigned long	towrite;
  unsigned long write;

  if (!p) {
    cerr << "애드립 파일을 열 수 없습니다 : " << filename << endl;
    return false;
  }
  audio_len = 0;
  while (p->update()) {
    for (towrite = rate / p->getrefresh(); towrite; towrite -= write) {
      write = ((int)towrite > buf_size ? buf_size : towrite);
      opl.update(buf, write);
      memcpy(&(audio_chunk[audio_len]), buf, write*2);
      audio_len += write*2;
    }
  }
  audio_head = audio_chunk;
  audio_at = audio_head;
  audio_remain = audio_len;
  return true;
}
Beispiel #3
0
void Parser::writeDataPacket(DataPacket* p, QFile& file)
{
    QTextStream opl(&file);
    const QString format = "MM-dd-yy hh:mm";
    QString datetime;

    datetime = p->time.toString( format );

    opl<<"Test Number: " << p->testnumber <<'\t'<< datetime << '\n'
       <<"Data Type: " << p->datatype <<'\n'
       <<"Units: " << p->units <<'\n'
       <<"Discard Value: " << p->discardvalue <<'\n'
       <<"Reading:\n";

    for(int i = 0; i < p->reading.size();++i){
        opl<<p->reading[i]<<'\n';
    }

    opl<<"Average: " << p->average <<'\n'
       <<"Median:  " << p->median <<'\n'
       <<"Minimum: " << p->minimum <<'\n'
       <<"Maximum: " << p->maximum <<'\n'
       <<"Angle: " << p->angle <<'\n'
       <<"Correlation: " << p->correlation <<'\n'
       <<'\n';
}
/**
 * Check whether classifier has abstract operations.
 * @param c   the classifier to check
 * @return true when classifier has abstract operations
 */
bool SimpleCodeGenerator::hasAbstractOps(UMLClassifier *c)
{
    UMLOperationList opl(c->getOpList());
    foreach (UMLOperation* op, opl ) {
        if(op->isAbstract())
            return true;
    }
    return false;
}
Beispiel #5
0
/**
 * Write all operations for a given class.
 * @param c   the concept we are generating code for
 * @param h   output stream for the header file
 */
void RubyWriter::writeOperations(UMLClassifier *c, QTextStream &h)
{
    //Lists to store operations  sorted by scope
    UMLOperationList oppub, opprot, oppriv;

    //sort operations by scope first and see if there are abstract methods
    UMLOperationList opl(c->getOpList());
    foreach (UMLOperation *op, opl) {
        switch(op->visibility()) {
        case Uml::Visibility::Public:
            oppub.append(op);
            break;
        case Uml::Visibility::Protected:
            opprot.append(op);
            break;
        case Uml::Visibility::Private:
            oppriv.append(op);
            break;
        default:
            break;
        }
    }

    QString classname(cleanName(c->name()));

    //write operations to file
    if (forceSections() || !oppub.isEmpty()) {
        writeOperations(classname, oppub, Uml::Visibility::Public, h);
    }

    if (forceSections() || !opprot.isEmpty()) {
        writeOperations(classname, opprot, Uml::Visibility::Protected, h);
    }

    if (forceSections() || !oppriv.isEmpty()) {
        writeOperations(classname, oppriv, Uml::Visibility::Private, h);
    }
}
Beispiel #6
0
void CSharpWriter::writeOperations(UMLClassifier *c, QTextStream &cs) {

    //Lists to store operations  sorted by scope
    UMLOperationList oppub,opprot,oppriv;

    bool isInterface = c->isInterface();
    bool generateErrorStub = true;

    oppub.setAutoDelete(false);
    opprot.setAutoDelete(false);
    oppriv.setAutoDelete(false);

    //sort operations by scope first and see if there are abstract methods
    UMLOperationList opl(c->getOpList());
    for (UMLOperation *op = opl.first(); op ; op = opl.next()) {
        switch (op->getVisibility()) {
          case Uml::Visibility::Public:
            oppub.append(op);
            break;
          case Uml::Visibility::Protected:
            opprot.append(op);
            break;
          case Uml::Visibility::Private:
            oppriv.append(op);
            break;
          default:
            break;
        }
    }

    // write realizations (recursive)
    UMLAssociationList realizations = c->getRealizations();

    if (!isInterface && !realizations.isEmpty()) {
        writeRealizationsRecursive(c, &realizations, cs);
    }

    // write public operations
    if (forceSections() || !oppub.isEmpty()) {
        cs << m_endl << m_container_indent << m_indentation << "#region Public methods" << m_endl << m_endl;
        writeOperations(oppub,cs,isInterface,false,generateErrorStub);
        cs << m_container_indent << m_indentation << "#endregion" << m_endl << m_endl;
    }

    // write protected operations
    if (forceSections() || !opprot.isEmpty()) {
        cs << m_endl << m_container_indent << m_indentation << "#region Protected methods" << m_endl << m_endl;
        writeOperations(opprot,cs,isInterface,false,generateErrorStub);
        cs << m_container_indent << m_indentation << "#endregion" << m_endl << m_endl;
    }

    // write private operations
    if (forceSections() || !oppriv.isEmpty()) {
        cs << m_endl << m_container_indent << m_indentation << "#region Private methods" << m_endl << m_endl;
        writeOperations(oppriv,cs,isInterface,false,generateErrorStub);
        cs << m_container_indent << m_indentation << "#endregion" << m_endl << m_endl;
    }

    // write superclasses abstract methods
    UMLClassifierList superclasses = c->getSuperClasses();

    if (!isInterface && !c->getAbstract() && !c->hasAbstractOps()
            && superclasses.count() > 0) {
        writeOverridesRecursive(&superclasses, cs);
    }

}