Ejemplo n.º 1
0
////////////////////////////////////////////////////////////////////
// debug
plString plNetMsgSDLState::AsString() const
{
    ISetDescName();     // set desc name for debug if necessary

    return plString::Format("object:%s, initial:%d, %s",
        ObjectInfo()->GetObjectName().c_str(), fIsInitialState, plNetMsgStreamedObject::AsString().c_str() );
}
Ejemplo n.º 2
0
  ObjectInfo Resolver::DestinationPath(const string &path) const
  {
    ObjectInfo oi = ObjectInfo(path, default_project);
    if (oi.project.id == "")
      oi.project.id = FindProject(oi.project.name);

    return oi;
  }
MtpObjectsModel::ObjectInfo MtpObjectsModel::getInfoById(mtp::u32 objectId) const
{
	mtp::msg::ObjectInfo oi(_session->GetObjectInfo(objectId));
	qint64 size = oi.ObjectCompressedSize;
	if (size == mtp::MaxObjectSize)
		size = _session->GetObjectIntegerProperty(objectId, mtp::ObjectProperty::ObjectSize);
	return ObjectInfo(fromUtf8(oi.Filename), oi.ObjectFormat, size);
}
Ejemplo n.º 4
0
ObjectInfo ObjectsTable::getItemInfo(long long objid) {
    std::stringstream str;
    str << "SELECT `template`, `spawnid` FROM `objects` WHERE `objectid` = '" << objid << "';";
    auto qr = Database::Query(str.str());
    if (qr == NULL) {

    } else {
        if (mysql_num_rows(qr) > 0) {
            auto row = mysql_fetch_row(qr);
            long lot = std::stol(row[0]);
            long long spawnid = -1;
            if (row[1] != NULL) {
                spawnid = std::stoll(row[1]);
            }
            return ObjectInfo(objid, lot, spawnid);
        }
    }
    return ObjectInfo(0, 0, 0);
}
Ejemplo n.º 5
0
void ComputeInterestingSceneParts( const SVector3& lightDir, const SMatrix4x4& cameraViewProj )
{
	bool hit = false;

	SVector3 sweepDir = lightDir;

	// camera frustum
	Frustum sceneFrustum( cameraViewProj );

	gSceneReceivers.clear();
	gSceneCasters.clear();
	gCasterBounds.setNull();
	gReceiverBounds.setNull();

	size_t n = gScene.size();
	for( size_t i = 0; i < n; ++i )
	{
		SceneEntity& obj = *gScene[i];
		CAABox aabb = obj.getAABB();
		aabb.transform( obj.mWorldMat );
		if( aabb.frustumCull( cameraViewProj ) )
		{
			SVector3 spherePos = aabb.getCenter();
			float sphereRadius = SVector3(aabb.getMax()-aabb.getMin()).length() / 2;
			if( sceneFrustum.TestSweptSphere( spherePos, sphereRadius, sweepDir ) )
			{
				hit = true;
				gSceneCasters.push_back( ObjectInfo(aabb,obj) ); // originally in view space
				gCasterBounds.extend( aabb );
			}
		}
		else
		{
			hit = true;
			gSceneCasters.push_back( ObjectInfo(aabb,obj) ); // originally in view space
			gSceneReceivers.push_back( ObjectInfo(aabb,obj) ); // originally in view space
			gCasterBounds.extend( aabb );
			gReceiverBounds.extend( aabb );
		}
	}
}
Ejemplo n.º 6
0
        void parseContents(QXmlStreamReader& stream)
        {
            stream.readNextStartElement();
            const QString key = stream.readElementText();

            stream.readNextStartElement();
            const auto lastModified = QDateTime::fromString(
                    stream.readElementText(), Qt::ISODate);

            stream.readNextStartElement();
            const auto etag = QByteArray::fromHex(
                    stream.readElementText().toLatin1());

            stream.readNextStartElement();
            const size_t size = stream.readElementText().toUInt();

            stream.readNextStartElement(); //Owner
            stream.readNextStartElement();
            auto ownerId = stream.readElementText().toLatin1();
            ownerId = QByteArray::fromHex(ownerId);

            stream.readNextStartElement();
            const QString ownerDisplayName = stream.readElementText();

            ObjectInfo::OwnerPtr owner;
            if (m_owrners.contains(ownerId))
            {
                owner = m_owrners[ownerId];
            }
            else
            {
                owner = std::make_shared<ObjectInfo::Owner>(ownerId,
                        ownerDisplayName);
            }
            stream.skipCurrentElement();

            stream.readNextStartElement();
            const QString storageClass = stream.readElementText();
            m_buckets.push_back(ObjectInfo(
                    key,
                    lastModified,
                    etag,
                    size,
                    owner,
                    storageClass));
            while (stream.readNext() == QXmlStreamReader::StartElement)
            {
            }
        }
Ejemplo n.º 7
0
int main(int argc, char **argv)
{
	char dcname[40];


	if( argc < 2 )
	{
		printf("usage: %s objects...\n",argv[0]);
		exit(1);
	}

	argv++;
	
	for( ; *argv != NULL; argv++ )
	{
		char *name = *argv;
		char *s;
		ObjInfo info;
		char *type;
		char tt[20];
				
		if( ObjectInfo(CurrentDir,name,(byte *)&info) != 0 ) 
		{
			fprintf(stderr,"could not locate %s : %x\n",name,Result2(CurrentDir));		
			continue;
		}
	
		switch( info.DirEntry.Type )
		{
		case Type_Directory: type = "d"; break;
		case Type_File: type = "f"; break;
		case Type_Link: type = "l"; break;
		default:
			type = tt;
			sprintf(tt,"%x",info.DirEntry.Type);
			break;	
		}
		DecodeMatrix(dcname,info.DirEntry.Matrix,info.DirEntry.Type);
		printf("%s %s %s\n",type,dcname,info.DirEntry.Name);
	}

	return 0;
}
Ejemplo n.º 8
0
/**
 * 内部用: wait処理
 * @param v squirrelVM
 * @param idx 該当 idx 以降にあるものを待つ
 */
void
Thread::_wait(HSQUIRRELVM v, int idx)
{
	_clearWait();
	_waitResult.clear();
	SQInteger max = sq_gettop(v);
	for (int i=idx;i<=max;i++) {
		switch (sq_gettype(v, i)) {
		case OT_INTEGER:
		case OT_FLOAT:
			// 数値の場合はタイムアウト待ち
			{
				SQInteger timeout;
				sq_getinteger(v, i, &timeout);
				if (timeout >= 0) {
					if (_waitTimeout < 0  || _waitTimeout > timeout) {
						_waitResult.getStack(v, i);
						_waitTimeout = timeout;
					}
				}
			}
			break;
		case OT_STRING:
			// 待ちリストに登録
			_waitList.append(ObjectInfo(v,i));
			break;
		case OT_INSTANCE:
			// オブジェクトに待ち登録してから待ちリストに登録
			{
				ObjectInfo o;
				o.getStackWeak(v,i);
				Object *obj = o;
				if (obj) {
					obj->addWait(self);
				}
				_waitList.append(o);
			}
			break;
		default:
			break;
		}
	}
}
Ejemplo n.º 9
0
    //-----------------------------------------------------------------------
    void CreateObjectOperator::add(const ObjectPtr& object, bool create)
    {
        assert(object);

        mObjectInfos.push_back(ObjectInfo());
        ObjectInfo& info = mObjectInfos.back();

        info.create = create;
        info.type = object->getType();
        info.name = object->getName();
        const PropertyList& properties = object->getProperties();
        for (PropertyList::const_iterator it = properties.begin(); it != properties.end(); ++it)
        {
            const PropertyDef& propertyDef = *it;
            if (object->getPropertyAsString(propertyDef.name) != propertyDef.defaultValue)
            {
                info.properties.insert(
                    PropertyNameVariantPairList::value_type(propertyDef.name, object->getProperty(propertyDef.name)));
            }
        }
    }
Ejemplo n.º 10
0
static void s_InitializeOrganelleProductRules(void)
{
    CFastMutexGuard GUARD(s_OrganelleProductRulesMutex);
    if (s_OrganelleProductRulesInitialized) {
        return;
    }
    s_OrganelleProductRules.Reset(new CSuspect_rule_set());
    string file = g_FindDataFile("organelle_products.prt");

    if ( !file.empty() ) {
        auto_ptr<CObjectIStream> in;
        in.reset(CObjectIStream::Open(file, eSerial_AsnText));
        string header = in->ReadFileHeader();
        in->Read(ObjectInfo(*s_OrganelleProductRules), CObjectIStream::eNoFileHeader);
    }
    if (!s_OrganelleProductRules->IsSet()) {
        size_t num_lines = sizeof (s_Defaultorganelleproducts) / sizeof (char *);
        string all_rules = "";
        for (size_t i = 0; i < num_lines; i++) {
            all_rules += s_Defaultorganelleproducts[i];
        }
        CNcbiIstrstream istr(all_rules.c_str());
        istr >> MSerial_AsnText >> *s_OrganelleProductRules;
    }
Ejemplo n.º 11
0
void
rm( char * name )
{
  DirEntry *	b;
  DirEntry *	m;
  word		no_entries;
  word		i;
  word		size;
  word		dirsize;
  Stream *	s;
  char		rname[ 128 ];
  word		isdir;
  word		islink;
  Dinfo		obinfo;  
  Object *	o = Locate( CurrentDir, name );

  
  if ( ObjectInfo(CurrentDir,name,obinfo.buff) != 0)
    {
      if (!fflag)
	fprintf(stderr,"Cannot find %s : %lx\n",name,
		Result2(CurrentDir));
      errors++;
      return;
    }
  
  islink = obinfo.DirEntry.Type & Type_Link;
  isdir  = o->Type & Type_Directory;
  
  if (iflag) 
    {
      fprintf(stderr,"rm: delete %s %s? ", 
	      (isdir ? "directory" : "file"), name);

      fflush(stderr);
      if (!confirm ())
	return;
    }
  
  /* If a simple file or directory, delete it */
  
  if ( islink || !(isdir && rflag))
    {
      del(name); 
      return;
    }
  
  /* More complicated case - scan a directory */
  
  s = Open(o,NULL,O_ReadOnly);
  
  if ( s == Null(Stream) )
    {
      fprintf(stderr,"Cannot open %s : %lx\n",name,Result2(o));
      errors++;
      return;
    }
  
  dirsize = GetFileSize(s);
  
  no_entries = dirsize/sizeof(DirEntry);
  
  if (no_entries > 0)
    {
      m = b = (DirEntry *) Malloc(dirsize);
      
      if (b == Null(DirEntry))
	{
	  fprintf(stderr,"rm: Out of memory\n");
	  exit(1);
	}
      
      size = Read(s,(char *)b,dirsize,-1);
      
      if ( size != dirsize)
	{
	  fprintf(stderr,"Read failure %lx\n",Result2(s));
	  errors++;
	  return;
	}
      
      for ( i = 0 ; i < no_entries; i++ )
	{ 
	  if (strcmp ("..", m->Name) && strcmp (".", m->Name))
	    {
	      strcpy (rname, name);
	      strcat (rname, "/");
	      strcat (rname, m->Name);
	      rm (rname);
	    }
	  m++;
	}
      
      Free(b);
    }
  
  Close(s);
  Close(o);

  del (name);

  return;
  
} /* rm */
Ejemplo n.º 12
0
 ObjectInfo Resolver::ParsePath(const string &path) const
 {
   return ObjectInfo(path, default_project);
 }
Ejemplo n.º 13
0
int main(int argc, const char* argv[])
{
    {{
        // set primitive value
        CSeq_id obj;
        CObjectInfo info(ObjectInfo(obj));
        CObjectInfo local(info.SetChoiceVariant(info.FindVariantIndex("local")));
        local.SetChoiceVariant(local.FindVariantIndex("id")).SetPrimitiveValueInt(234);
        cout << MSerial_AsnText << obj;
    }}

    {{
        CSeq_loc obj;
        CObjectInfo info(ObjectInfo(obj));

        // set choice variant
        info.SetChoiceVariant(info.FindVariantIndex("null"));
        cout << MSerial_AsnText << obj;

        // change choice variant
        CObjectInfo seqid(info.SetChoiceVariant(info.FindVariantIndex("empty")));
        CObjectInfo local(seqid.SetChoiceVariant(seqid.FindVariantIndex("local")));
        local.SetChoiceVariant(local.FindVariantIndex("id")).SetPrimitiveValueInt(987);
        cout << MSerial_AsnText << obj;
        
        // there is no way to reset choice variant
        // this does not work:
        //info.SetChoiceVariant(0);
    }}

    {{
        CSeq_id_set obj;
        CObjectInfo info(ObjectInfo(obj));
        // 'implicit' class has one member with no name
        CObjectInfo mem(info.SetClassMember(1));

        // add container element
        CObjectInfo elem(mem.AddNewPointedElement());
        CObjectInfo local(elem.SetChoiceVariant(elem.FindVariantIndex("local")));
        local.SetChoiceVariant(local.FindVariantIndex("id")).SetPrimitiveValueInt(345);

        // add container element
        elem = mem.AddNewPointedElement();
        local = elem.SetChoiceVariant(elem.FindVariantIndex("local"));
        local.SetChoiceVariant(local.FindVariantIndex("str")).SetPrimitiveValueString("345string");

        // add container element
        elem = mem.AddNewPointedElement();
        CObjectInfo prf = elem.SetChoiceVariant(elem.FindVariantIndex("prf"));
        prf.SetClassMember(prf.FindMemberIndex("name")).SetPrimitiveValueString("prfname");
        prf.SetClassMember(prf.FindMemberIndex("release")).SetPrimitiveValueString("prfrelease");
        prf.SetClassMember(prf.FindMemberIndex("version")).SetPrimitiveValueInt(567);

        cout << MSerial_AsnText << obj;

        // unset class member
        // only optional members can be unset
        if (prf.FindClassMember("version").IsSet()) {
            prf.FindClassMember("version").Reset();
        }
        cout << MSerial_AsnText << obj;
    }}

    return 0;
}
Ejemplo n.º 14
0
int COMSSAMerge::Run()
{    

    try {

	CArgs args = GetArgs();


    CRef <COMSSASearch> MySearch(new COMSSASearch);

    ESerialDataFormat InFileType(eSerial_Xml), OutFileType(eSerial_Xml);

    bool obz2(false);  // output bzip2 compressed?
    bool ibz2(false);  // input bzip2 compressed?

    if(args["ox"]) OutFileType = eSerial_Xml;
    else if(args["ob"]) OutFileType = eSerial_AsnBinary;
    else if(args["ot"]) OutFileType = eSerial_AsnText;
    else if(args["obz2"]) {
        OutFileType = eSerial_Xml;
        obz2 = true;
    }
    else ERR_POST(Fatal << "output file type not given");

    if(args["ix"]) InFileType = eSerial_Xml;
    else if(args["ib"]) InFileType = eSerial_AsnBinary;
    else if(args["it"]) InFileType = eSerial_AsnText;
    else if(args["ibz2"]) {
        InFileType = eSerial_Xml;
        ibz2 = true;
    }
    else ERR_POST(Fatal << "input file type not given");


    // loop thru input files
    if ( args["i"].AsString() != "") {
        ifstream is(args["i"].AsString().c_str());
        bool Begin(true);
        if(!is)
            ERR_POST(Fatal << "unable to open input file list " << args["i"].AsString());
        while(!is.eof()) {
            string iFileName;
            NcbiGetline(is, iFileName, "\x0d\x0a");
            if(iFileName == "" || is.eof()) continue;
            try {
                CRef <COMSSASearch> InSearch(new COMSSASearch);
                CSearchHelper::ReadCompleteSearch(iFileName, InFileType, ibz2, *InSearch);
//                InSearch->ReadCompleteSearch(iFileName, InFileType, ibz2);
                if(Begin) {
                    Begin = false;
                    MySearch->CopyCMSSearch(InSearch);
                }
                else {
                    // add
                    MySearch->AppendSearch(InSearch);
                }
            }
            catch(CException& e) {
                ERR_POST(Fatal << "exception: " << e.what());
                return 1;
            }
        }
    }
    else if ( args.GetNExtra() ) {
        for (size_t extra = 1;  extra <= args.GetNExtra();  extra++) {
            CRef <COMSSASearch> InSearch(new COMSSASearch);
            CSearchHelper::ReadCompleteSearch(args[extra].AsString(), InFileType, ibz2, *InSearch);
            //InSearch->ReadCompleteSearch(args[extra].AsString(), InFileType, ibz2);
            try {
                if(extra == 1) {
                    // copy
                    MySearch->CopyCMSSearch(InSearch);
                }
                else {
                    // add
                    MySearch->AppendSearch(InSearch);
                }
            }
            catch(CException& e) {
                ERR_POST(Fatal << "exception: " << e.what());
                return 1;
            }
        }
    }
 
    // write out the new search

    auto_ptr <CNcbiOfstream> raw_out;
    auto_ptr <CCompressionOStream> compress_out;
    auto_ptr <CObjectOStream> txt_out;
    
    if( obz2 ) {
        raw_out.reset(new CNcbiOfstream(args["o"].AsString().c_str()));
        compress_out.reset( new CCompressionOStream (*raw_out, 
                                                     new CBZip2StreamCompressor(), 
                                                     CCompressionStream::fOwnProcessor)); 
        txt_out.reset(CObjectOStream::Open(OutFileType, *compress_out)); 
    }
    else {
        txt_out.reset(CObjectOStream::Open(args["o"].AsString().c_str(), OutFileType));
    }


//    auto_ptr <CObjectOStream> txt_out(
//         CObjectOStream::Open(args["o"].AsString(), OutFileType));

    if(txt_out.get()) {
        SetUpOutputFile(txt_out.get(), OutFileType);
        if (args["sw"]) {
            txt_out->Write(ObjectInfo(*(*MySearch->SetResponse().begin())));
	}
        else {
            txt_out->Write(ObjectInfo(*MySearch));
        }
        txt_out->Flush();
        txt_out->Close();
    }


    } catch (NCBI_NS_STD::exception& e) {
	ERR_POST(Fatal << "Exception in COMSSAMerge::Run: " << e.what());
    }

    return 0;
}