コード例 #1
0
bool DataObject::duplicateDependents(QMap<DataObjectPtr, DataObjectPtr> &duplicatedMap) {
  // FIXME: redo
#if 0
  // work with a copy of the data object list
  dataObjectList.lock().readLock();
  DataObjectList dol = dataObjectList;
  dataObjectList.lock().unlock();

  for (DataObjectList::Iterator i = dol.begin(); i != dol.end(); ++i) {
    if ((*i)->uses(this)) {
      if (duplicatedMap.contains(*i)) {
        (duplicatedMap[*i])->replaceDependency(this, duplicatedMap[this]);
      } else {
        DataObjectPtr newObject = (*i)->makeDuplicate(duplicatedMap);
        dataObjectList.lock().writeLock();
        dataObjectList.append(newObject.data());
        dataObjectList.lock().unlock();
        (duplicatedMap[*i])->replaceDependency(this, duplicatedMap[this]);
        (*i)->duplicateDependents(duplicatedMap);
      }
    }
  }
#endif

  return true;
}
コード例 #2
0
ファイル: CtpmmdZitContainer.cpp プロジェクト: SeanGo/warmgui
bool CCtpmmdZitContainer::NewData(DataObjectPtr dop)
{
    char* buf = (char*)dop->GetData();
    size_t len = dop->GetDataLength();

    if ((DataObject::MARKET_DATA_TYPE)(*(int*)buf) == DataObject::MARKET_DATA_TYPE_CTPMMD) {
        buf += sizeof(int), len -= sizeof(int);
        CTPMMD* ctpmmd = (CTPMMD*)buf;
        if (_data_len > (size_t)ctpmmd->fIndex) {
            _curpos = (size_t)ctpmmd->fIndex;
            memcpy(_ctpmmd + _curpos, ctpmmd, sizeof(CTPMMD));
#           ifdef _DEBUG
            /*CTPMMD* pctpmmd = _ctpmmd + _curpos;
            MYTRACE(L"CTPMMD %.02f %.02f %.02f %.02f %.02f %.02f %.02f\n",
                pctpmmd->fIndex,
                pctpmmd->m_time,
                pctpmmd->LastPrice,
                pctpmmd->Volume,
                pctpmmd->relVolume,
                pctpmmd->OpenInterest,
                pctpmmd->relInterest);*/
#           endif //_DEBUG
            _world.renew_world(_ctpmmd + _curpos);
            ++_count;
        } else {
            //shift to left
            //but not now
        }
        return true;
    }
    return false;
}
コード例 #3
0
bool DataObject::deleteDependents() {
  // FIXME: redo
#if 0
  dataObjectList.lock().readLock();
  DataObjectList dol = dataObjectList;
  dataObjectList.lock().unlock();
  for (DataObjectList::Iterator i = dol.begin(); i != dol.end(); ++i) {
    bool user = (*i)->uses(this);
    if (!user) {
      for (VectorMap::Iterator j = _outputVectors.begin(); !user && j != _outputVectors.end(); ++j) {
        user = (*i)->uses(j.value().data());
      }
      for (ScalarMap::Iterator j = _outputScalars.begin(); !user && j != _outputScalars.end(); ++j) {
        user = (*i)->uses(j.value().data());
      }
      for (StringMap::Iterator j = _outputStrings.begin(); !user && j != _outputStrings.end(); ++j) {
        user = (*i)->uses(j.value().data());
      }
    }
    if (user) {
      DataObjectPtr dop = *i;
      dataObjectList.lock().writeLock();
      dataObjectList.removeAll(dop);
      dataObjectList.lock().unlock();
      dop->deleteDependents();
    }
  }
#endif

  return true;
}
コード例 #4
0
ファイル: CtpmmdZitContainer.cpp プロジェクト: SeanGo/warmgui
bool CZitdataContainer::NewData(DataObjectPtr dop)
{
    char* buf = (char*)dop->GetData();
    size_t len = dop->GetDataLength();

    if ((DataObject::MARKET_DATA_TYPE)(*(int*)buf) == DataObject::EUCLID_CALUC_TO_TRANSMIT) {
        buf += sizeof(int), len -= sizeof(int);

        return _zit_data.AppendData(buf, len);
    }
    return false;
}
コード例 #5
0
ファイル: DataContainer.cpp プロジェクト: SeanGo/warmgui
GLYPH_CHANGED_TYPE IDataContainer::AddData(DataObjectPtr dop)
{
    GLYPH_CHANGED_TYPE change = GLYPH_CHANGED_TYPE_NONE;
    MARKET_DATA_TYPE datatype = (MARKET_DATA_TYPE)*(int*)(dop->GetData());

    if (NewData(dop)) {
        //TCHAR name[MAX_PATH];
        //CChineseCodeLib::Gb2312ToUnicode(name, MAX_PATH, _name);
        //MYTRACE(L"container name is %s\n", name);

        //calculators
        for (CalConstIter iter = _cals.begin(); iter != _cals.end(); iter++) {
            (*iter)->NewData(this, datatype);
        }

        //canvases
        for (DataCanvasArray::const_iterator iter = _canvases.begin(); iter != _canvases.end(); iter++) {
            GLYPH_CHANGED_TYPE c = (*iter)->NewData(this, datatype);
            change = (GLYPH_CHANGED_TYPE)((int)change | (int)c);
        }

        //data graphs
        for (DataGraphConstIter iter = _dgraph.begin(); iter != _dgraph.end(); iter++) {
            GLYPH_CHANGED_TYPE c = (*iter)->NewData(this, datatype);
            change = (GLYPH_CHANGED_TYPE)((int)change | (int)c);
        }
    }

    return change;
}
コード例 #6
0
ファイル: document.cpp プロジェクト: jmlee4301/kst
/** return a list of data objects where all dependencies appear earlier in the list */
ObjectList<DataObject> Document::sortedDataObjectList() {
  ObjectList<DataObject> sorted;
  ObjectList<DataObject> raw = objectStore()->getObjects<DataObject>();

  sorted.clear();


  // set the flag for all primitives: not strictly necessary
  // since it should have been done in the constructor, but...
  PrimitiveList all_primitives = objectStore()->getObjects<Primitive>();
  int n = all_primitives.size();
  for (int i=0; i<n; i++) {
    all_primitives[i]->setFlag(true);
  }

  // now unset the flags of all output primitives to indicate their parents haven't been
  // put in the sorted list yet
  n = raw.size();
  for (int i=0; i<n; i++) {
    raw[i]->setOutputFlags(false);
  }

  // now place into the sorted list all data objects whose inputs haven't got parents
  // or whose inputs have parents which are already in the sorted list.
  // do this at most n^2 times, which is worse than worse case.
  int i=0;
  while (!raw.isEmpty() && (++i <= n*n)) {
    DataObjectPtr D = raw.takeFirst();
    if (D->inputFlagsSet()) {
      D->setOutputFlags(true);
      sorted.append(D);
    } else {
      raw.append(D); // try again later
    }
  }

  if ((i== n*n) && (n>1)) {
    qDebug() << "Warning: loop detected, File will not be able to be loaded correctly!";
    while (!raw.isEmpty()) {
      DataObjectPtr D = raw.takeFirst();
      sorted.append(D);
    }
  }

  return sorted;
}
コード例 #7
0
 foreach (DataObjectPtr s, objectStore()->getObjects<DataObject>()) {
   s->save(xml);
 }
コード例 #8
0
ファイル: document.cpp プロジェクト: jmlee4301/kst
 foreach (DataObjectPtr s, dataObjects) {
   s->save(xml);
 }
コード例 #9
0
ファイル: sdo_utils.cpp プロジェクト: CloCkWeRX/sdo
/* {{{ sdo_parse_offset_param
 * internal function to get an sdo property offset from a zval parameter.
 * The value may have been passed as a SDO_Model_Property, an xpath or a property index.
 * Calling functions should catch SDORuntimeException.
 */
int sdo_parse_offset_param (DataObjectPtr dop, zval *z_offset,
	const Property **return_property, const char **return_xpath,
	int property_required,
	int quiet TSRMLS_DC) {

	long			 prop_index;
	const Property  *property_p;
	const char		*xpath;
//	char			*class_name;
//	char		    *space;


	if (!z_offset) {
		/* get here with a statement like $sdo[] = 'some value'; */
		if (!quiet) {
			const char *space, *class_name = get_active_class_name(&space TSRMLS_CC);
			sdo_throw_exception_ex (sdo_unsupportedoperationexception_class_entry, 0, 0 TSRMLS_CC,
				"%s%s%s(): cannot append a value - this object is not many-valued",
				class_name, space, get_active_function_name(TSRMLS_C));
		}
		return FAILURE;
	}

	switch(Z_TYPE_P(z_offset)) {
	case IS_NULL:
		if (!quiet) {
			const char *space, *class_name = get_active_class_name(&space TSRMLS_CC);
			sdo_throw_exception_ex (sdo_unsupportedoperationexception_class_entry, 0, 0 TSRMLS_CC,
				"%s%s%s(): parameter is NULL",
				class_name, space, get_active_function_name(TSRMLS_C));
		}
		return FAILURE;
	case IS_STRING:
		xpath = Z_STRVAL_P(z_offset);

		/* If the type is open, then it's OK for the xpath offset to
		 * specify an unknown property. But even an open type may have
		 * defined properties, so we still need to try for one.
		 */
		if (property_required || dop->hasProperty(xpath)) {
			/* exception will be thrown if xpath is invalid */
			property_p = &dop->getProperty(xpath);
		} else {
			property_p = NULL;
		}
		break;
	case IS_LONG:
	case IS_BOOL:
	case IS_RESOURCE:
	case IS_DOUBLE:
		if (Z_TYPE_P(z_offset) == IS_DOUBLE) {
			if (!quiet) {
				const char *space, *class_name = get_active_class_name(&space TSRMLS_CC);
				php_error(E_WARNING, "%s%s%s(): double parameter %f rounded to %i",
					class_name, space, get_active_function_name(TSRMLS_C),
					Z_DVAL_P(z_offset), (long)Z_DVAL_P(z_offset));
			}
			prop_index =(long)Z_DVAL_P(z_offset);
		} else {
			prop_index = Z_LVAL_P(z_offset);
		}
		/* Note an open type may not be specified using a property index,
		 * so no need to repeat the check that was done for IS_STRING above.
         */
		property_p = &dop->getProperty(prop_index);
		xpath = property_p->getName();
		break;
	case IS_OBJECT:
		if (!instanceof_function(Z_OBJCE_P(z_offset), sdo_model_property_class_entry TSRMLS_CC)) {
			if (!quiet) {
				const char *space, *class_name = get_active_class_name(&space TSRMLS_CC);
				sdo_throw_exception_ex (sdo_unsupportedoperationexception_class_entry, 0, 0 TSRMLS_CC,
					"%s%s%s(): expects object parameter to be SDO_Model_Property, %s given",
					class_name, space, get_active_function_name(TSRMLS_C),
					Z_OBJCE_P(z_offset)->name);
			}
			return FAILURE;
		}
		property_p = sdo_model_property_get_property(z_offset TSRMLS_CC);
		xpath = property_p->getName();
		break;
	default:
		if (!quiet) {
			const char *space, *class_name = get_active_class_name(&space TSRMLS_CC);
			php_error(E_ERROR, "%s%s%s(): internal error - invalid dimension type %i",
				class_name, space, get_active_function_name(TSRMLS_C),
				Z_TYPE_P(z_offset));
		}
		return FAILURE;
	}

	if (return_xpath) {
		*return_xpath = xpath;
	}

	if (return_property) {
		*return_property = property_p;
	}

	return SUCCESS;
}
コード例 #10
0
    bool EqualityHelper::compareitem(DataObjectPtr to, DataObjectPtr from, const Property& p)
    {
        switch (p.getTypeEnum())
        {
        case Type::BooleanType:
            return (to->getBoolean(p) == from->getBoolean(p));
        case Type::ByteType:
            return (to->getByte(p) == from->getByte(p));
        case Type::CharacterType:
            return (to->getCharacter(p) == from->getCharacter(p));
        case Type::IntegerType: 
            return (to->getInteger(p) == from->getInteger(p));
        case Type::ShortType:
            return (to->getShort(p) == from->getShort(p));
        case Type::DoubleType:
            return (to->getDouble(p) == from->getDouble(p));
        case Type::FloatType:
            return (to->getFloat(p) ==  from->getFloat(p));
        case Type::LongType:
            return (to->getLong(p) == from->getLong(p));
        case Type::DateType:
            return (to->getDate(p).getTime() ==  from->getDate(p).getTime());
        case Type::BigDecimalType: 
        case Type::BigIntegerType: 
        case Type::UriType:
        case Type::StringType:
            {
                unsigned int siz =     from->getLength(p);
                if (siz != to->getLength(p)) return false;

                if (siz > 0)
                {
                    wchar_t * buff = new wchar_t[siz];
                    wchar_t * buft = new wchar_t[siz];
                    from->getString(p, buff, siz);
                    to->getString(p, buft, siz);
                    for (unsigned int i=0;i< siz; i++)
                    {
                        if (buff[i] != buft[i])
                        {
                            delete buff;
                            delete buft;
                            return false;
                        }
                    }
                    delete[] buff;
                    delete[] buft;
                }
                return true;
            }
        case Type::BytesType:
            {
                unsigned int siz =     from->getLength(p);
                if (siz != to->getLength(p)) return false;

                if (siz > 0)
                {
                    char * buff = new char[siz];
                    char * buft = new char[siz];
                    from->getBytes(p, buff, siz);
                    to->getBytes(p, buft, siz);
                    for (unsigned int i=0;i< siz; i++)
                    {
                        if (buff[i] != buft[i])
                        {
                            delete buff;
                            delete buft;
                            return false;
                        }
                    }
                    delete buff;
                    delete buft;
                }
                return true;
            }
        default:
            return true;
        }  // switch
    }
コード例 #11
0
    bool EqualityHelper::internalEqual(DataObjectPtr dataObject1,
                                                DataObjectPtr dataObject2,
                                            bool fullEqual)
    {

    
        PropertyList pl = dataObject1->getInstanceProperties();
        for (unsigned int i=0;i < pl.size(); i++)
        {
            // data objects are only compared the deep equality case
            if (pl[i].getType().isDataObjectType())
            {
                if (!fullEqual) 
                {
                    continue;
                }
                else
                {
                    if (pl[i].isMany())
                    {
                        DataObjectList& dolold = dataObject1->getList(pl[i]);
                        DataObjectList& dolnew = dataObject2->getList(pl[i]);
                        if (dolnew.size() != dolold.size()) return false;

                        for (unsigned int i=0;i< dolold.size(); i++)
                        {
                            if (!internalEqual(dolold[i], dolnew[i], true))
                            {
                                return false;
                            }
                        }
                    }
                    else 
                    {
                        if (!internalEqual(
                            dataObject1->getDataObject(pl[i]),
                            dataObject2->getDataObject(pl[i]), true))
                        {
                            return false;
                        }
                    }
                }
            }
            else 
            {
                if (pl[i].isMany())
                {
                    DataObjectList& dolold = dataObject1->getList(pl[i]);
                    DataObjectList& dolnew = dataObject2->getList(pl[i]);
                    if (dolold.size() != dolnew.size()) return false;
                    if (!comparelist(dolold, dolnew, pl[i].getTypeEnum())) return false;
                }
                else 
                {
                    if (!compareitem(dataObject1,dataObject2, pl[i]))
                    {
                        return false;
                    }
                } // else
            } 
        } 
        return true;
    }
コード例 #12
0
void DataObject::replaceDependency(DataObjectPtr oldObject, DataObjectPtr newObject) {

  // find all connections from this object to old object

  // vectors
  for (VectorMap::Iterator j = oldObject->outputVectors().begin(); j != oldObject->outputVectors().end(); ++j) {
    for (VectorMap::Iterator k = _inputVectors.begin(); k != _inputVectors.end(); ++k) {
      if (j.value().data() == k.value().data()) {
        // replace input with the output from newObject
        _inputVectors[k.key()] = (newObject->outputVectors())[j.key()];
      }
    }
    // also replace dependencies on vector stats
    QHashIterator<QString, Scalar*> scalarDictIter(j.value()->scalars());
    for (ScalarMap::Iterator k = _inputScalars.begin(); k != _inputScalars.end(); ++k) {
      while (scalarDictIter.hasNext()) {
        scalarDictIter.next();
        if (scalarDictIter.value() == k.value()) {
          _inputScalars[k.key()] = (((newObject->outputVectors())[j.key()])->scalars())[scalarDictIter.key()];
        }
      }
    }
  }

  // matrices
  for (MatrixMap::Iterator j = oldObject->outputMatrices().begin(); j != oldObject->outputMatrices().end(); ++j) {
    for (MatrixMap::Iterator k = _inputMatrices.begin(); k != _inputMatrices.end(); ++k) {
      if (j.value().data() == k.value().data()) {
        // replace input with the output from newObject
        _inputMatrices[k.key()] = (newObject->outputMatrices())[j.key()];
      }
    }
    // also replace dependencies on matrix stats
    QHashIterator<QString, Scalar*> scalarDictIter(j.value()->scalars());
    for (ScalarMap::Iterator k = _inputScalars.begin(); k != _inputScalars.end(); ++k) {
      while (scalarDictIter.hasNext()) {
        scalarDictIter.next();
        if (scalarDictIter.value() == k.value()) {
          _inputScalars[k.key()] = (((newObject->outputMatrices())[j.key()])->scalars())[scalarDictIter.key()];
        }
      }
    }
  }

  // scalars
  for (ScalarMap::Iterator j = oldObject->outputScalars().begin(); j != oldObject->outputScalars().end(); ++j) {
    for (ScalarMap::Iterator k = _inputScalars.begin(); k != _inputScalars.end(); ++k) {
      if (j.value().data() == k.value().data()) {
        // replace input with the output from newObject
        _inputScalars[k.key()] = (newObject->outputScalars())[j.key()];
      }
    }
  }

  // strings
  for (StringMap::Iterator j = oldObject->outputStrings().begin(); j != oldObject->outputStrings().end(); ++j) {
    for (StringMap::Iterator k = _inputStrings.begin(); k != _inputStrings.end(); ++k) {
      if (j.value().data() == k.value().data()) {
        // replace input with the output from newObject
        _inputStrings[k.key()] = (newObject->outputStrings())[j.key()];
      }
    }
  }
}