Esempio n. 1
0
bool DynamicObjectImp::setAttributeByPath(QStringList pathComponents, DataVariant& value, bool swap)
{
   if (!value.isValid())
   {
      return false;
   }

   QString finalName = pathComponents.back();
   pathComponents.pop_back();

   string loopType = "DynamicObject";
   DynamicObject* pLoopObj = dynamic_cast<DynamicObject*>(this);
   DynamicObject* pCurObj = pLoopObj;
   for (QStringList::const_iterator iter = pathComponents.begin();
      iter != pathComponents.end(); ++iter)
   {
      if (pLoopObj == NULL || loopType != "DynamicObject")
      {
         return false;
      }

      pCurObj = pLoopObj;
      DataVariant& attrValue = pCurObj->getAttribute(iter->toStdString());
      loopType = attrValue.getTypeName();
      pLoopObj = attrValue.getPointerToValue<DynamicObject>();

      if ((pLoopObj != NULL) && (loopType != "DynamicObject"))
      {
         return false;
      }

      if (pLoopObj == NULL)
      {
         FactoryResource<DynamicObject> pNewObj;
         if (pCurObj != NULL)
         {
            pCurObj->setAttribute(iter->toStdString(), *pNewObj.get());
            DataVariant& currentValue = pCurObj->getAttribute(iter->toStdString());
            loopType = currentValue.getTypeName();
            pLoopObj = currentValue.getPointerToValue<DynamicObject>();
         }
      }
   }

   if (pLoopObj == NULL || loopType != "DynamicObject")
   {
      return false;
   }

   pCurObj = pLoopObj;
   DynamicObjectImp* const pCurObjImp = dynamic_cast<DynamicObjectImp*>(pCurObj);
   VERIFY(pCurObjImp != NULL);
   return pCurObjImp->setAttribute(finalName.toStdString(), value, swap);
}
    bool RecyclableObject::IsWritableDataOnlyDetectionBitSet()
    {
        if (DynamicType::Is(this->GetTypeId()))
        {
            DynamicObject* obj = DynamicObject::FromVar(this);
            return obj->GetTypeHandler()->IsWritableDataOnlyDetectionBitSet() ||
                (obj->HasObjectArray() && obj->GetObjectArrayOrFlagsAsArray()->IsWritableDataOnlyDetectionBitSet());
        }

        return false;
    }
Esempio n. 3
0
    bool RecyclableObject::HasOnlyWritableDataProperties()
    {
        if (DynamicType::Is(this->GetTypeId()))
        {
            DynamicObject* obj = DynamicObject::FromVar(this);
            return obj->GetTypeHandler()->GetHasOnlyWritableDataProperties() &&
                (!obj->HasObjectArray() || obj->GetObjectArrayOrFlagsAsArray()->HasOnlyWritableDataProperties());
        }

        return true;
    }
Esempio n. 4
0
DynamicObject& Exception::getDetails()
{
   if(mDetails->isNull())
   {
      DynamicObject details;
      details->setType(Map);
      *mDetails = details;
   }

   return *mDetails;
}
Esempio n. 5
0
DynamicObject* DisplayQueryOptions::toDynamicObject() const
{
   DynamicObject* pDynObj = QueryOptions::toDynamicObject();
   VERIFYRV(pDynObj != NULL, NULL);

   pDynObj->setAttribute(UNIQUE_NAME, mUniqueName);
   pDynObj->setAttribute(CHECKED, mbQueryActive);
   pDynObj->setAttribute(ORDER, mOrder);

   return pDynObj;
}
Esempio n. 6
0
void Cal3dModel::render(bool select_mode) {
  // TODO Make this into a matrix?
//  Render *render = RenderSystem::getInstance().getRenderer();
//  render->rotate(m_rotate,0.0f,0.0f,1.0f); //so zero degrees points east

  DynamicObjectList::iterator I = m_dos.begin();
  DynamicObjectList::const_iterator Iend = m_dos.end();
  while (I != Iend) {
    DynamicObject* dyno = *I++;
    dyno->render(select_mode);
  }
}
Esempio n. 7
0
const var EnviJSONRPC::toArray (const StringPairArray &stringPairArray)
{
	var ret = empty(false);
	DynamicObject *dso = ret.getDynamicObject();

	for (int i=0; i<stringPairArray.size(); i++)
	{
		dso->setProperty (stringPairArray.getAllKeys() [i], stringPairArray.getAllValues() [i]);
	}

	return (ret);
}
Esempio n. 8
0
 void RecyclableObject::ClearWritableDataOnlyDetectionBit()
 {
     if (DynamicType::Is(this->GetTypeId()))
     {
         DynamicObject* obj = DynamicObject::FromVar(this);
         obj->GetTypeHandler()->ClearWritableDataOnlyDetectionBit();
         if (obj->HasObjectArray())
         {
             obj->GetObjectArrayOrFlagsAsArray()->ClearWritableDataOnlyDetectionBit();
         }
     }
 }
Esempio n. 9
0
DynamicObject*
ObjectAccessor::GetDynamicObject(WorldObject const &u, uint64 guid)
{
    DynamicObject * ret = GetObjectInWorld(guid, (DynamicObject*)NULL);
    if(!ret)
        return NULL;
    if(ret->GetMapId() != u.GetMapId())
        return NULL;
    if(ret->GetInstanceId() != u.GetInstanceId())
        return NULL;
    return ret;
}
Esempio n. 10
0
vector<ImportDescriptor*> LayerImporter::getImportDescriptors(const string& filename, bool reportErrors)
{
   vector<ImportDescriptor*> descriptors;
   if (!filename.empty())
   {
      MessageLog* pLog = NULL;
      if (reportErrors == true)
      {
         Service<MessageLogMgr> pLogMgr;
         pLog = pLogMgr->getLog();
      }

      XmlReader xml(pLog);
      XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* pDoc = xml.parse(filename, "metadata");
      DOMElement* pRootElement = NULL;
      if (pDoc != NULL)
      {
         pRootElement = pDoc->getDocumentElement();
      }
      if (pRootElement != NULL)
      {
         for (DOMNode* pChild = pRootElement->getFirstChild();
            pChild != NULL;
            pChild = pChild->getNextSibling())
         {
            if (pChild->getNodeType() == DOMNode::ELEMENT_NODE)
            {
               DOMElement* pChildElement = static_cast<DOMElement*>(pChild);
               string cNodeName = A(pChildElement->getNodeName());

               ImportDescriptor* pImportDescriptor = ModelImporter::populateImportDescriptor(pChildElement, filename);
               if (pImportDescriptor != NULL)
               {
                  DataDescriptor* pDataDescriptor = pImportDescriptor->getDataDescriptor();
                  if (NULL != pDataDescriptor)
                  {
                     DynamicObject* pMetadataZ = pDataDescriptor->getMetadata();
                     VERIFYRV(pMetadataZ, descriptors);
                     if (!pMetadataZ->getAttributeByPath("Layer/Import Options/Use Pixel Coordinates").isValid())
                     {
                        pMetadataZ->setAttributeByPath("Layer/Import Options/Use Pixel Coordinates", false);
                     }
                  }
                  descriptors.push_back(pImportDescriptor);
               }
            }
         }
      }
   }

   return descriptors;
}
Esempio n. 11
0
bool Map::isValid(
   DynamicObject& obj,
   ValidatorContext* context)
{
   bool rval = true;

   if(!obj.isNull() && obj->getType() == monarch::rt::Map)
   {
      Validators::iterator i;
      for(i = mValidators.begin(); i != mValidators.end(); ++i)
      {
         // only add a "." if this is not a root map
         if(context->getDepth() != 0)
         {
            context->pushPath(".");
         }
         context->pushPath(i->first);
         if(obj->hasMember(i->first))
         {
            // do not short-circuit to ensure all keys tested
            if(!i->second.validator->isValid(obj[i->first], context))
            {
               rval = false;
            }
         }
         else if(!i->second.validator->isOptional(context))
         {
            rval = false;
            DynamicObject detail =
               context->addError("monarch.validation.MissingField", &obj);
            detail["validator"] = "monarch.validator.Map";
            detail["message"] = "A required field has not been specified.";
            detail["key"] = i->first;
         }
         context->popPath();
         if(context->getDepth() > 0)
         {
            context->popPath();
         }
      }
   }
   else
   {
      rval = false;
      DynamicObject detail =
         context->addError("monarch.validation.TypeError", &obj);
      detail["validator"] = "monarch.validator.Map";
      detail["message"] = "The given object type must a mapping (Map) type";
   }

   return rval;
}
Esempio n. 12
0
void WebServer::cleanup()
{
   // reset container
   mContainer->clear();
   DynamicObject domains;
   domains->append("*");
   mContainer->setDefaultDomains(domains);

   // clean up
   mHostAddress.setNull();
   mSslContext.setNull();
   mSocketDataPresenterList.setNull();
}
Esempio n. 13
0
//==============================================================================
void MidiSelectProcessor::getStateInformation (MemoryBlock &destData)
{
    // Use json for better forward-compatibility (not just splat)
    
    DynamicObject *data = new DynamicObject;
    data->setProperty("lowerNote", lowerNote);
    data->setProperty("upperNote", upperNote);
    
    String json = JSON::toString(var(data), true);
    
    MemoryOutputStream stream(destData, false);
    stream.write(json.toUTF8(), json.length());
}
Esempio n. 14
0
void LoadSave::loadModulations(SynthBase* synth,
                               const Array<var>* modulations) {
  synth->clearModulations();
  var* modulation = modulations->begin();

  for (; modulation != modulations->end(); ++modulation) {
    DynamicObject* mod = modulation->getDynamicObject();
    std::string source = mod->getProperty("source").toString().toStdString();
    std::string destination = mod->getProperty("destination").toString().toStdString();
    mopo::ModulationConnection* connection = synth->getModulationBank().get(source, destination);
    synth->setModulationAmount(connection, mod->getProperty("amount"));
  }
}
void PMixInterpolationSpaceLayout::updateComponents()
{
//  for (int i = getNumChildComponents(); --i >= 0;)
//  {
//    if (InterpolationSpacePreset* const pc = dynamic_cast <InterpolationSpacePreset*> (getChildComponent (i)))
//      pc->update();
//  }
  
  for (int i = audioEngine.getDoc().getNumNodes(); --i >= 0;)
  {
    const AudioProcessorGraph::Node::Ptr f (audioEngine.getDoc().getNode (i));
    
    if (!InternalPluginFormat::isInternalFormat(f->getProcessor()->getName()))
    {
      Array<InterpolationSpacePreset*> comps;
      getComponentsForNode(f->nodeID, comps);
      Array<var>* presets = f->properties.getVarPointer("presets")->getArray();
      
      // if the number of presets for this node has changed then delete the components and re-create
      if (comps.size() != presets->size())
      {
        for (int componentIdx = 0; componentIdx<comps.size(); componentIdx++)
        {
          removeChildComponent(comps[componentIdx]);
          delete comps[componentIdx];
        }
        
        for (int presetIdx = 0; presetIdx < presets->size(); presetIdx++)
        {
          DynamicObject* obj = presets->getReference(presetIdx).getDynamicObject();
          
          String label = obj->getProperty("name");
          InterpolationSpacePreset* const comp = new InterpolationSpacePreset(audioEngine, label, f->nodeID, obj->getProperty("uid"), audioEngine.getDoc().getNodeColour(f->nodeID)  );
          String componentID;
          componentID << "p." << (int) f->nodeID << "." << presetIdx;
          comp->setComponentID(componentID);
          float r = MIN_RADIUS + (RADIUS_RANGE * (float) obj->getProperty("radius"));
          float x = getWidth() * (float) obj->getProperty("x");
          float y = getHeight() * (float) obj->getProperty("y");
          
          comp->setSize(r, r);
          comp->setCentrePosition(x, y);
          comp->update();
          
          addAndMakeVisible (comp);
        }
      }
    }
    
  }
}
Esempio n. 16
0
// TODO: expose as utility function?
static string _encode(
   RdfType type, const char* value, const char* datatype = NULL)
{
   string rval;

   // FIXME: escape

   // <value>
   if(type == RDF_TYPE_IRI)
   {
      rval.push_back('<');
      rval.append(value);
      rval.push_back('>');
   }
   // value^^<datatype>
   else if(type == RDF_TYPE_TYPED_LITERAL)
   {
      // FIXME: this is called with <> wrapped datatypes, despite func docs.
      // Adjust datatype to an unwrapped version if needed.
      const char* dt = datatype;
      size_t dtlen = strlen(dt);
      if(dtlen > 1 && dt[0] == '<' && dt[dtlen - 1] == '>')
      {
         dt++;
         dtlen -= 2;
      }

      // use canonical form for xsd:double
      if(strncmp(datatype, XSD_DOUBLE, dtlen) == 0)
      {
         DynamicObject d;
         d = value;
         rval = StringTools::format("%1.6e", d->getDouble());
      }
      else
      {
         rval.assign(value);
      }
      rval.append("^^");
      rval.push_back('<');
      rval.append(dt, dtlen);
      rval.push_back('>');
   }
   // default
   else
   {
      rval.assign(value);
   }

   return rval.c_str();
}
Esempio n. 17
0
DynamicObject *DynamicObject::FindObject(const char *name)
{
    DynamicObject *obj = 0;
    Lock();
    for (int i = 0; i < containedobjects.size(); i++) {
        if (!strcmp(containedobjects[i]->GetName(), name)) {
            obj = containedobjects[i];
            obj->IncRef();
            break;
        }
    }
    Unlock();
    return obj;
}
Esempio n. 18
0
    void EmpowerOrb(bool all)
    {
        if(!Orb[OrbsEmpowered])
            return;
        uint8 random = rand()%3;
        if(all) {
            m_creature->RemoveDynObject(SPELL_RING_OF_BLUE_FLAMES);
            for(uint8 i = 0; i < 4; ++i) {
                if(!Orb[i]) return;
                Orb[i]->CastSpell(m_creature, SPELL_RING_OF_BLUE_FLAMES);
                Orb[i]->SetUInt32Value(GAMEOBJECT_FACTION, 35);
                Orb[i]->setActive(true);
                Orb[i]->Refresh();
            }
        } else {
            float x,y,z, dx,dy,dz;
            Orb[random]->GetPosition(x,y,z);
            for(uint8 i = 0; i < 4; ++i) {
                DynamicObject* Dyn = m_creature->GetDynObject(SPELL_RING_OF_BLUE_FLAMES);
                if(Dyn) {
                    Dyn->GetPosition(dx,dy,dz);
                    if(x == dx && dy == y && dz == z) {
                        Dyn->RemoveFromWorld();
                        break;
                    }
                }
            }
            Orb[random]->CastSpell(m_creature, SPELL_RING_OF_BLUE_FLAMES);
            Orb[random]->SetUInt32Value(GAMEOBJECT_FACTION, 35);
            Orb[random]->setActive(true);
            Orb[random]->Refresh();
            ++OrbsEmpowered;
        }
        ++EmpowerCount;

        switch(EmpowerCount) {
        case 1:
            DoScriptText(SAY_KALEC_ORB_READY1, m_creature);
            break;
        case 2:
            DoScriptText(SAY_KALEC_ORB_READY2, m_creature);
            break;
        case 3:
            DoScriptText(SAY_KALEC_ORB_READY3, m_creature);
            break;
        case 4:
            DoScriptText(SAY_KALEC_ORB_READY4, m_creature);
            break;
        }
    }
Esempio n. 19
0
bool Nitf::EngrdaParser::fromDynamicObject(const DynamicObject& input,
        std::ostream& output,
        size_t& numBytesWritten,
        std::string &errorMessage) const
{
    if (output.tellp() < 0 || static_cast<uint64_t>(output.tellp()) > std::numeric_limits<size_t>::max())
    {
        return false;
    }
    size_t sizeIn = std::max<size_t>(0, static_cast<size_t>(output.tellp()));
    size_t sizeOut(sizeIn);

    try
    {
        output << sizeString(dv_cast<std::string>(input.getAttribute(ENGRDA::RESRC)), 20);
        unsigned int cnt = dv_cast<unsigned int>(input.getAttribute(ENGRDA::RECNT));
        output << toString(cnt, 3);
        for (size_t recNum = 0; recNum < cnt; ++recNum)
        {
            const DynamicObject& rec = dv_cast<const DynamicObject>(
                                           input.getAttribute(StringUtilities::toXmlString(recNum)));
            std::string lbl = dv_cast<std::string>(rec.getAttribute(ENGRDA::ENGLBL));
            output << toString(lbl.size(), 2);
            output << sizeString(lbl, lbl.size());
            output << toString(dv_cast<unsigned int>(rec.getAttribute(ENGRDA::ENGMTXC)), 4);
            output << toString(dv_cast<unsigned int>(rec.getAttribute(ENGRDA::ENGMTXR)), 4);
            output << sizeString(dv_cast<std::string>(rec.getAttribute(ENGRDA::ENGTYP)), 1);
            unsigned int dts = dv_cast<unsigned int>(rec.getAttribute(ENGRDA::ENGDTS));
            output << toString(dts, 1);
            output << sizeString(dv_cast<std::string>(rec.getAttribute(ENGRDA::ENGDATU)), 2);
            const Blob* data = dv_cast<Blob>(&rec.getAttribute(ENGRDA::ENGDATA));
            const std::vector<unsigned char>& rawData = data->get();
            unsigned int datc = rawData.size() / dts;
            output << toString(datc, 8);
            output.write(reinterpret_cast<const char*>(&(rawData.front())), rawData.size());
        }
    }
    catch (const std::bad_cast&)
    {
        return false;
    }

    if (output.tellp() < 0 || static_cast<uint64_t>(output.tellp()) > std::numeric_limits<size_t>::max())
    {
        return false;
    }
    sizeOut = static_cast<size_t>(output.tellp());
    numBytesWritten = sizeOut - sizeIn;
    return true;
}
Esempio n. 20
0
/**
 * Recursively applies context to the given input object.
 *
 * @param ctx the context to use.
 * @param usedCtx the used context values.
 * @param predicate the related predicate or NULL if none.
 * @param in the input object.
 * @param out the contextualized output object.
 */
static void _applyContext(
   DynamicObject& ctx, DynamicObject& usedCtx,
   const char* predicate, DynamicObject& in, DynamicObject& out)
{
   if(in.isNull())
   {
      out.setNull();
   }
   else
   {
      // initialize output
      DynamicObjectType inType = in->getType();
      out->setType(inType);

      if(inType == Map)
      {
         // add context to each property in the map
         char* tmp = NULL;
         DynamicObjectIterator i = in.getIterator();
         while(i->hasNext())
         {
            // compact predicate
            DynamicObject& next = i->next();
            DynamicObject cp(NULL);
            const char* p;
            if(strcmp(i->getName(), "@") == 0)
            {
               p = "@";
            }
            else
            {
               cp = _compactString(ctx, usedCtx, NULL, i->getName(), &tmp);
               p = cp;
            }
            // recurse
            _applyContext(ctx, usedCtx, p, next, out[p]);
         }
         free(tmp);
      }
      else if(inType == Array)
      {
         // apply context to each object in the array
         DynamicObjectIterator i = in.getIterator();
         while(i->hasNext())
         {
            DynamicObject& next = i->next();
            _applyContext(ctx, usedCtx, predicate, next, out->append());
         }
      }
      // only strings need context applied, numbers & booleans don't
      else if(inType == String)
      {
         // compact string
         char* tmp = NULL;
         out = _compactString(ctx, usedCtx, predicate, in->getString(), &tmp);
         free(tmp);
      }
   }
}
Esempio n. 21
0
int JSON_EncodeValue(json_buf* buf, DynamicObject& obj)
{
	switch (obj.type)
	{
	case DO_UNKNOWN:
		return json_write_null(buf);
	case DO_INTEGER:
		return json_write_integer(buf, obj);
	case DO_BOOLEAN:
		return json_write_bool(buf, obj);
	case DO_NUMBER:
		return json_write_number(buf, obj);
	case DO_STRING:
		return json_write_string(buf, obj);
	case DO_ARRAY:
		{
			int len = json_putch(buf, '[');
            size_t size = obj.size();
			for (size_t i = 0; i < size; i++)
			{
				len += JSON_EncodeValue(buf, obj[i]);
				if (i != size - 1)
					len += json_putch(buf, ',');
			}
			len += json_putch(buf, ']');
			return len;
		}
	case DO_OBJECT:
		{
			int len = json_putch(buf, '{');
			std::vector<std::string> keys;
            obj.propertyList(keys);
            size_t size = keys.size();
			for (size_t i = 0; i < size; i++)
			{
				std::string& key = keys[i];
				len += json_write_string(buf, (char*)key.c_str());
				len += json_putch(buf, ':');
				len += JSON_EncodeValue(buf, obj[key]);
				if (i != keys.size() - 1)
					len += json_putch(buf, ',');
			}
			len += json_putch(buf, '}');
			return len;
		}
	default:
		return 0;
	}
}
Esempio n. 22
0
bool Messenger::exchange(
   UserId peerId,
   Url* url, BtpMessage* out, BtpMessage* in, UserId userId, UserId agentId,
   uint32_t timeout)
{
   bool rval = true;

   if(userId != 0)
   {
      // get user profile
      ProfileRef p;
      if(!mNode->getLoginData(agentId == 0 ? userId : agentId, NULL, &p))
      {
         ExceptionRef e = new Exception(
            "Could not do BTP exchange. Not logged in.",
            "bitmunk.node.Messenger.NotLoggedIn");
         BM_ID_SET(e->getDetails()["userId"], userId);
         BM_ID_SET(e->getDetails()["agentId"], agentId);
         Exception::set(e);
         rval = false;
      }
      else if(!p.isNull())
      {
         // set user ID and profile for outgoing secure message
         out->setUserId(userId);
         out->setAgentProfile(p);

         // set public key source for incoming secure message
         in->setPublicKeySource(mNode->getPublicKeyCache());
      }
   }

   // do btp exchange
   if(rval)
   {
      // if nodeuser is set, override peer ID with it
      DynamicObject vars;
      url->getQueryVariables(vars);
      if(vars->hasMember("nodeuser"))
      {
         peerId = BM_USER_ID(vars["nodeuser"]);
      }

      rval = mClient.exchange(peerId, url, out, in, timeout);
   }

   return rval;
}
Esempio n. 23
0
Nitf::TreState Nitf::SectgaParser::isTreValid(const DynamicObject& tre, ostream& reporter) const
{
   TreState status(VALID);
   set<string>             testSet;
   unsigned int numFields = 0;

   testSet.clear();
   status = MaxState(status, testTagValidBcsASet(tre, reporter,
      &numFields, SECTGA::SEC_ID, testSet, true, true, false));

   status = MaxState(status, testTagValidBcsASet(tre, reporter,
      &numFields, SECTGA::SEC_BE, testSet, true, true, false));

   status = MaxState(status, testTagValueRange<unsigned int>(tre, reporter,
      &numFields, SECTGA::RESERVED001, 0U, 0U));

   unsigned int totalFields = tre.getNumAttributes();
   if (status != INVALID && totalFields != numFields)
   {
      reporter << "Total fields in the Dynamic Object(" <<
         totalFields << ") did not match the number found(" << numFields << ") ";
      status = INVALID;
   }

   if (status == INVALID)
   {
      reporter << " INVALID fields found in the SECTGA TAG/SDE\n" ;
   }
   else if (status == SUSPECT)
   {
      reporter << " SUSPECT fields found in the SECTGA TAG/SDE\n" ;
   }

   return status;
}
Esempio n. 24
0
void DatabaseClient::appendSetSql(string& sql, DynamicObject& params)
{
   bool first = true;
   DynamicObjectIterator i = params.getIterator();
   while(i->hasNext())
   {
      DynamicObject& param = i->next();
      if(first)
      {
         first = false;
         sql.append(" ");
      }
      else
      {
         sql.append(",");
      }

      // append name
      if(param->hasMember("tableAlias"))
      {
         sql.append(param["tableAlias"]->getString());
         sql.push_back('.');
      }
      sql.append(param["name"]->getString());
      sql.append("=?");
   }
}
Esempio n. 25
0
void DatabaseClient::appendValuesSql(string& sql, DynamicObject& params)
{
   string values;

   bool first = true;
   DynamicObjectIterator i = params.getIterator();
   while(i->hasNext())
   {
      DynamicObject& name = i->next()["name"];
      if(first)
      {
         first = false;
         sql.append(" (");
         values.append(" VALUES (?");
      }
      else
      {
         sql.append(",");
         values.append(",?");
      }

      // append unaliased name
      sql.push_back('`');
      sql.append(name->getString());
      sql.push_back('`');
   }

   if(!first)
   {
      sql.append(")");
      values.append(")");
   }

   sql.append(values);
}
Esempio n. 26
0
bool DirectiveService::getDirectives(
   BtpAction* action, DynamicObject& in, DynamicObject& out)
{
   bool rval = false;

   UserId userId;
   if(mNode->checkLogin(action, &userId))
   {
      rval = true;

      // turn user ID into a key
      char key[22];
      snprintf(key, 22, "%" PRIu64, userId);

      // return user's directive cache
      mCacheLock.lock();
      {
         if(mDirectives->hasMember(key))
         {
            out = mDirectives[key];
         }
         else
         {
            out->setType(Map);
         }
      }
      mCacheLock.unlock();
   }

   return rval;
}
Esempio n. 27
0
bool ModuleDescriptor::updateSettings(DynamicObject& settings) const
{
   VERIFY(mCanCache);
   QByteArray moduleBlob;
   QDataStream moduleStream(&moduleBlob, QIODevice::WriteOnly);
   moduleStream << QString::fromStdString(getId());
   moduleStream << static_cast<quint64>(mFileDate.getStructured());
   moduleStream << mFileSize;
   moduleStream << QString::fromStdString(mFileName);
   moduleStream << QString::fromStdString(getName());
   moduleStream << QString::fromStdString(mVersion);
   moduleStream << QString::fromStdString(mDescription);
   moduleStream << mPlugInTotal;
   moduleStream << QString::fromStdString(mValidationKey);
   moduleStream << mModuleVersion;
   moduleStream << QString::fromStdString(mInstantiateSymbol);
   vector<PlugInDescriptorImp*>::const_iterator ppDescriptor;
   bool plugInSettingsSaved = true;
   for (ppDescriptor=mPlugins.begin(); ppDescriptor!=mPlugins.end(); ++ppDescriptor)
   {
      PlugInDescriptorImp* pDescriptor = *ppDescriptor;
      if (pDescriptor == NULL)
      {
         return false;
      }
      plugInSettingsSaved = pDescriptor->updateSettings(moduleStream);
      if (!plugInSettingsSaved)
      {
         return false;
      }
   }
   settings.setAttribute("details", string(moduleBlob.toBase64().constData()));
   //NOTE: not serializing mCanCache on purpose, since calling this function means it's being cached.
   return true;
}
Esempio n. 28
0
bool Nitf::DesSubheader::importMetadata(const ossimPropertyInterface *pHeader, RasterDataDescriptor *pDescriptor)
{
    VERIFY(pHeader != NULL && pDescriptor != NULL);

    FactoryResource<DynamicObject> pDesSubheaderMetadata;
    VERIFY(pDesSubheaderMetadata.get() != NULL);

    VERIFY(Header::importMetadata(pHeader, pDescriptor, pDesSubheaderMetadata.get()));
    VERIFY(pDescriptor != NULL);

    DynamicObject* pMetadata = pDescriptor->getMetadata();
    VERIFY(pMetadata != NULL);

    pMetadata->setAttributeByPath(getMetadataPath(), *pDesSubheaderMetadata.get());
    return true;
}
Esempio n. 29
0
/**
 * Sets a subject's predicate to the given object value. If a value already
 * exists, it will be appended to an array. If the object value is NULL, then
 * the subject's predicate will be converted to an array.
 *
 * @param s the subject.
 * @param p the predicate.
 * @param o the object, NULL to only convert s[p] to an array.
 */
static void _setPredicate(DynamicObject& s, const char* p, const char* o)
{
   // FIXME: must sort objects or keep array order?
   if(s->hasMember(p))
   {
      if(s[p]->getType() != Array)
      {
         DynamicObject tmp = s[p];
         s[p] = DynamicObject();
         s[p]->append(tmp);
      }
      if(o != NULL)
      {
         s[p]->append(o);
      }
   }
   else if(o == NULL)
   {
      s[p]->setType(Array);
   }
   else
   {
      s[p] = o;
   }
}
Esempio n. 30
0
/* Check if a JSON-LD object is a specific type. */
static bool _isType(DynamicObject& in, const char* type)
{
   bool rval = false;

   if(in->hasMember("a"))
   {
      DynamicObject& a = in["a"];
      switch(a->getType())
      {
         case String:
         {
            rval = (a == type);
            break;
         }
         case Array:
         {
            DynamicObjectIterator i = a.getIterator();
            while(!rval && i->hasNext())
            {
               DynamicObject& next = i->next();
               rval = (next == type);
            }
            break;
         }
         default:
            break;
      }
   }

   return rval;
}