double AbstractGetIntPropertyFunctor::getPropertyAsDouble(const void* instance, const NumberFormat* numberFormat/*, int arrayIndex*/) const
{
	return getPropertyAsInt(instance/*, arrayIndex*/);
}
float AbstractGetIntPropertyFunctor::getPropertyAsFloat(const void* instance, const NumberFormat* numberFormat/*, int arrayIndex*/) const
{
	return static_cast<float>(getPropertyAsInt(instance/*, arrayIndex*/));
}
BaseLib::Strings::String AbstractGetIntPropertyFunctor::getProperty(const void* instance, const NumberFormat* numberFormat/*, int arrayIndex*/) const
{
	if (numberFormat == NULL) numberFormat = NumberFormat::getDefault();
	int intResult = getPropertyAsInt(instance/*, arrayIndex*/);
	return numberFormat->format(intResult);
}
bool AbstractGetIntPropertyFunctor::getPropertyAsBool(const void* instance, const NumberFormat* numberFormat/*, int arrayIndex*/) const
{
	int intResult = getPropertyAsInt(instance/*, arrayIndex*/);
	return intResult != 0;
}
Ejemplo n.º 5
0
    void
    operator()(const CommunicatorDescriptorPtr& desc)
    {
        //
        // Figure out the configuration file name for the communicator
        // (if it's a service, it's "config_<service name>", if it's
        // the server, it's just "config").
        //
        string filename = "config";
        ServiceDescriptorPtr svc = ServiceDescriptorPtr::dynamicCast(desc);
        if(svc)
        {
            filename += "_" + svc->name;
            _desc->services->push_back(svc->name);
        }

        PropertyDescriptorSeq& props = _desc->properties[filename];
        PropertyDescriptorSeq communicatorProps = desc->propertySet.properties;

        //
        // If this is a service communicator and the IceBox server has Admin
        // enabled or Admin endpoints configured, we ignore the server-lifetime attributes
        // of the service object adapters and assume it's set to false.
        //
        bool ignoreServerLifetime = false;
        if(svc)
        {
            if(_iceVersion == 0 || _iceVersion >= 30300)
            {
                if(getPropertyAsInt(_desc->properties["config"], "Ice.Admin.Enabled") > 0 ||
                   getProperty(_desc->properties["config"], "Ice.Admin.Endpoints") != "")
                {
                    ignoreServerLifetime = true;
                }
            }
        }
        //
        // Add the adapters and their configuration.
        //
        for(AdapterDescriptorSeq::const_iterator q = desc->adapters.begin(); q != desc->adapters.end(); ++q)
        {
            _desc->adapters.push_back(new InternalAdapterDescriptor(q->id,
                                                                    ignoreServerLifetime ? false : q->serverLifetime));

            props.push_back(createProperty("# Object adapter " + q->name));
            PropertyDescriptor prop = removeProperty(communicatorProps, q->name + ".Endpoints");
            prop.name = q->name + ".Endpoints";
            props.push_back(prop);
            props.push_back(createProperty(q->name + ".AdapterId", q->id));
            if(!q->replicaGroupId.empty())
            {
                props.push_back(createProperty(q->name + ".ReplicaGroupId", q->replicaGroupId));
            }

            //
            // Ignore the register process attribute if the server is using Ice >= 3.3.0
            //
            if(_iceVersion != 0 && _iceVersion < 30300)
            {
                if(q->registerProcess)
                {
                    props.push_back(createProperty(q->name + ".RegisterProcess", "1"));
                    _desc->processRegistered = true;
                }
            }
        }

        _desc->logs.insert(_desc->logs.end(), desc->logs.begin(), desc->logs.end());

        const string dbsPath = _node->dataDir + "/servers/" + _desc->id + "/dbs/";
        for(DbEnvDescriptorSeq::const_iterator p = desc->dbEnvs.begin(); p != desc->dbEnvs.end(); ++p)
        {
            props.push_back(createProperty("# Database environment " + p->name));
            if(p->dbHome.empty())
            {
                _desc->dbEnvs.push_back(new InternalDbEnvDescriptor(p->name, p->properties));
                props.push_back(createProperty("Freeze.DbEnv." + p->name + ".DbHome", dbsPath + p->name));
            }
            else
            {
                props.push_back(createProperty("Freeze.DbEnv." + p->name + ".DbHome", p->dbHome));
            }
        }

        //
        // Copy the communicator descriptor properties.
        //
        if(!communicatorProps.empty())
        {
            if(svc)
            {
                props.push_back(createProperty("# Service descriptor properties"));
            }
            else
            {
                props.push_back(createProperty("# Server descriptor properties"));
            }
            copy(communicatorProps.begin(), communicatorProps.end(), back_inserter(props));
        }

        //
        // For Ice servers > 3.3.0 escape the properties.
        //
        if(_iceVersion == 0 || _iceVersion >= 30300)
        {
            for(PropertyDescriptorSeq::iterator p = props.begin(); p != props.end(); ++p)
            {
                if(p->name.find('#') != 0 || !p->value.empty())
                {
                    p->name = escapeProperty(p->name, true);
                    p->value = escapeProperty(p->value);
                }
            }
        }
    }