Ejemplo n.º 1
0
    void DecoratorTime::load(int version, const char* agentType, const properties_t& properties)
    {
        super::load(version, agentType, properties);

        for (propertie_const_iterator_t it = properties.begin(); it != properties.end(); ++it)
        {
			const property_t& p = (*it);
			behaviac::string p_name(p.name);
			behaviac::string p_value(p.value);

			if (p_name == "Time")
			{
				if (StringUtils::IsValidString(p.value))
				{
					size_t pParenthesis = p_value.find_first_of('(');

					if (pParenthesis == (size_t)-1)
					{
						behaviac::string typeName;
						this->m_time_var = Condition::LoadRight(p.value, typeName);
					}
					else
					{
						this->m_time_m = Action::LoadMethod(p.value);
					}
				}
			}
        }
    }
Ejemplo n.º 2
0
	void State::load(int version, const char* agentType, const properties_t& properties)
	{
		super::load(version, agentType, properties);

		for (propertie_const_iterator_t it = properties.begin(); it != properties.end(); ++it)
		{
			const property_t& p = (*it);

			if (strcmp(p.name, "Method") == 0)
			{
				if (p.value[0] != '\0')
				{
					this->m_method = Action::LoadMethod(p.value);
				}
			}
			else if (strcmp(p.name, "IsEndState") == 0)
			{
				if (p.value[0] != '\0')
				{
					if (StringUtils::StrEqual(p.value, "true"))
					{
						this->m_bIsEndState = true;
					}
				}//if (p.value[0] != '\0')
			}
		}
	}
Ejemplo n.º 3
0
    void BehaviorNode::load(int version, const char* agentType, const properties_t& properties)
    {
        BEHAVIAC_UNUSED_VAR(version);
        BEHAVIAC_UNUSED_VAR(agentType);
        BEHAVIAC_UNUSED_VAR(properties);

        for (propertie_const_iterator_t it = properties.begin(); it != properties.end(); ++it)
        {
            const property_t& p = (*it);

            if (StringUtils::StrEqual(p.name, "EnterAction"))
            {
                if (p.value[0] != '\0')
                {
                    this->m_enterAction = Action::LoadMethod(p.value);
                }//if (p.value[0] != '\0')

            }
            else if (StringUtils::StrEqual(p.name, "ExitAction"))
            {
                if (p.value[0] != '\0')
                {
                    this->m_exitAction = Action::LoadMethod(p.value);
                }//if (p.value[0] != '\0')
            }
        }

        {
            const char* nodeType = this->GetObjectTypeName();
            Workspace::GetInstance()->BehaviorNodeLoaded(nodeType, properties);
        }
    }
Ejemplo n.º 4
0
    void WaitFrames::load(int version, const char* agentType, const properties_t& properties)
    {
        super::load(version, agentType, properties);

        for (propertie_const_iterator_t it = properties.begin(); it != properties.end(); ++it)
        {
            const property_t& p = (*it);

            if (!strcmp(p.name, "Frames"))
            {
                const char* pParenthesis = strchr(p.value, '(');

                if (pParenthesis == 0)
                {
                    behaviac::string typeName;
                    behaviac::string propertyName;
                    this->m_frames_var = Condition::LoadRight(p.value, typeName);

                }
                else
                {
                    //method
                    this->m_frames_method = Action::LoadMethod(p.value);
                }
            }
        }
    }
Ejemplo n.º 5
0
    void Query::load(int version, const char* agentType, const properties_t& properties)
    {
        super::load(version, agentType, properties);

        if (properties.size() > 0)
        {
            for (propertie_const_iterator_t it = properties.begin(); it != properties.end(); ++it)
            {
                const property_t& p = (*it);

                if (strcmp(p.name, "Domain") == 0)
                {
                    m_domain = p.value;
                }
                else if (strcmp(p.name, "Descriptors") == 0)
                {
                    SetDescriptors(p.value);
                }
                else
                {
                    //BEHAVIAC_ASSERT(0, "unrecognised property %s", p.name);
                }
            }
        }
    }
Ejemplo n.º 6
0
    void ReferencedBehavior::load(int version, const char* agentType, const properties_t& properties)
    {
        super::load(version, agentType, properties);

        for (propertie_const_iterator_t it = properties.begin(); it != properties.end(); ++it)
        {
            const property_t& p = (*it);

            if (strcmp(p.name, "ReferenceFilename") == 0)
            {
                this->m_referencedBehaviorPath = p.value;

                bool bOk = Workspace::GetInstance()->Load(this->m_referencedBehaviorPath.c_str());
                BEHAVIAC_UNUSED_VAR(bOk);

                BEHAVIAC_ASSERT(bOk);

            }
            else if (strcmp(p.name, "Task") == 0)
            {
                BEHAVIAC_ASSERT(!StringUtils::IsNullOrEmpty(p.value));
                CMethodBase* m = Action::LoadMethod(p.value);
                //BEHAVIAC_ASSERT(m is CTaskMethod);

                this->m_taskMethod = (CTaskMethod*)m;

            }
            else
            {
                //BEHAVIAC_ASSERT(0, "unrecognised property %s", p.name);
            }
        }
    }
Ejemplo n.º 7
0
    void Condition::load(int version, const char* agentType, const properties_t& properties)
    {
        super::load(version, agentType, properties);

        behaviac::string typeName;
        behaviac::string comparatorName;

        for (propertie_const_iterator_t it = properties.begin(); it != properties.end(); ++it)
        {
            const property_t& p = (*it);

            if (strcmp(p.name, "Operator") == 0)
            {
                comparatorName = p.value;
            }
            else if (strcmp(p.name, "Opl") == 0)
            {
                const char* pParenthesis = strchr(p.value, '(');

                if (pParenthesis == 0)
                {
					this->m_opl = LoadLeft(p.value, typeName);
                }
                else
                {
                    this->m_opl_m = Action::LoadMethod(p.value);
                }
            }
            else if (strcmp(p.name, "Opr") == 0)
            {
                const char* pParenthesis = strchr(p.value, '(');

                if (pParenthesis == 0)
                {
                    this->m_opr = LoadRight(p.value, typeName);
                }
                else
                {
                    this->m_opr_m = Action::LoadMethod(p.value);

                    if (this->m_opr_m)
                    {
                        this->m_opr_m->GetReturnTypeName(typeName);
                    }
                }
            }
            else
            {
                //BEHAVIAC_ASSERT(0, "unrecognised property %s", p.name);
            }
        }

        if (!comparatorName.empty() && (this->m_opl || this->m_opl_m) && (this->m_opr || this->m_opr_m))
        {
            this->m_comparator = Condition::Create(typeName.c_str(), comparatorName.c_str(), this->m_opl, this->m_opl_m, this->m_opr, this->m_opr_m);
        }
    }
Ejemplo n.º 8
0
    void Event::load(int version, const char* agentType, const properties_t& properties)
    {
        super::load(version, agentType, properties);

        behaviac::string typeName;
        behaviac::string propertyName;
        behaviac::string comparatorName;

        for (propertie_const_iterator_t it = properties.begin(); it != properties.end(); ++it)
        {
            const property_t& p = (*it);

            if (strcmp(p.name, "EventName") == 0)
            {
                //method
                this->m_event = Action::LoadMethod(p.value);

            }
            else if (strcmp(p.name, "ReferenceFilename") == 0)
            {
                this->m_referencedBehaviorPath = p.value;

            }
            else if (strcmp(p.name, "TriggeredOnce") == 0)
            {
                if (string_icmp(p.value, "true") == 0)
                {
                    this->m_bTriggeredOnce = true;
                }

            }
            else if (strcmp(p.name, "TriggerMode") == 0)
            {
                if (string_icmp(p.value, "Transfer") == 0)
                {
                    this->m_triggerMode = TM_Transfer;

                }
                else if (string_icmp(p.value, "Return") == 0)
                {
                    this->m_triggerMode = TM_Return;

                }
                else
                {
                    BEHAVIAC_ASSERT(0, "unrecognised trigger mode %s", p.value);
                }

            }
            else
            {
                //BEHAVIAC_ASSERT(0, "unrecognised property %s", p.name);
            }
        }
    }
Ejemplo n.º 9
0
bool zmq::stream_engine_t::init_properties (properties_t & properties) {
    if (peer_address.empty()) return false;
    properties.insert (std::make_pair("Peer-Address", peer_address));

    //  Private property to support deprecated SRCFD
    std::ostringstream stream;
    stream << (int)s;
    std::string fd_string = stream.str();
    properties.insert(std::make_pair("__fd", fd_string));
    return true;
}
Ejemplo n.º 10
0
    void DecoratorLog::load(int version, const char* agentType, const properties_t& properties)
    {
        super::load(version, agentType, properties);

        for (propertie_const_iterator_t it = properties.begin(); it != properties.end(); ++it)
        {
            const property_t& p = (*it);

            if (strcmp(p.name, "Log") == 0)
            {
                this->m_message = p.value;
            }
        }
    }
Ejemplo n.º 11
0
    void Action::load(int version, const char* agentType, const properties_t& properties)
    {
        super::load(version, agentType, properties);

        for (propertie_const_iterator_t it = properties.begin(); it != properties.end(); ++it)
        {
            const property_t& p = (*it);

            if (strcmp(p.name, "Method") == 0)
            {
                if (p.value[0] != '\0')
                {
                    this->m_method = Action::LoadMethod(p.value);
                }
            }
            else if (strcmp(p.name, "ResultOption") == 0)
            {
                if (strcmp(p.value, "BT_INVALID") == 0)
                {
                    m_resultOption = BT_INVALID;

                }
                else if (strcmp(p.value, "BT_FAILURE") == 0)
                {
                    m_resultOption = BT_FAILURE;

                }
                else if (strcmp(p.value, "BT_RUNNING") == 0)
                {
                    m_resultOption = BT_RUNNING;

                }
                else
                {
                    m_resultOption = BT_SUCCESS;
                }
            }
            else if (strcmp(p.name, "ResultFunctor") == 0)
            {
                if (p.value[0] != '\0')
                {
                    this->m_resultFunctor = LoadMethod(p.value);
                }
            }
            else
            {
                //BEHAVIAC_ASSERT(0, "unrecognised property %s", p.name);
            }
        }
    }
Ejemplo n.º 12
0
	void FSM::load(int version, const char* agentType, const properties_t& properties)
	{
		super::load(version, agentType, properties);

		for (propertie_const_iterator_t it = properties.begin(); it != properties.end(); ++it)
		{
			const property_t& p = (*it);

			if (strcmp(p.name, "initialid") == 0)
			{
				this->m_initialId = atoi(p.value);
			}
		}
	}
Ejemplo n.º 13
0
    void Compute::load(int version, const char* agentType, const properties_t& properties) {
        super::load(version, agentType, properties);

        behaviac::string typeName;
        behaviac::string propertyName;

        for (propertie_const_iterator_t it = properties.begin(); it != properties.end(); ++it) {
            const property_t& p = (*it);

            if (StringUtils::StringEqual(p.name, "Opl")) {
                //this->m_opl = Condition::LoadLeft(p.value, typeName);
                this->m_opl = AgentMeta::ParseProperty(p.value);
            } else if (StringUtils::StringEqual(p.name, "Operator")) {
                BEHAVIAC_ASSERT(StringUtils::StringEqual(p.value, "Add")
                                || StringUtils::StringEqual(p.value, "Sub")
                                || StringUtils::StringEqual(p.value, "Mul")
                                || StringUtils::StringEqual(p.value, "Div"));

                this->m_operator = OperationUtils::ParseOperatorType(p.value);

            } else if (StringUtils::StringEqual(p.name, "Opr1")) {
                const char* pParenthesis = strchr(p.value, '(');

                if (pParenthesis == 0) {
                    //this->m_opr1 = Condition::LoadRight(p.value, typeName);
                    this->m_opr1 = AgentMeta::ParseProperty(p.value);
                } else {
                    //method
                    //this->m_opr1_m = Action::LoadMethod(p.value);
                    this->m_opr1 = AgentMeta::ParseMethod(p.value);
                }
            } else if (StringUtils::StringEqual(p.name, "Opr2")) {
                const char* pParenthesis = strchr(p.value, '(');

                if (pParenthesis == 0) {
                    this->m_opr2 = AgentMeta::ParseProperty(p.value);
                    //this->m_opr2 = Condition::LoadRight(p.value, typeName);
                } else {
                    //method
                    //this->m_opr2_m = Action::LoadMethod(p.value);
                    this->m_opr2 = AgentMeta::ParseMethod(p.value);
                }
            } else {
                //BEHAVIAC_ASSERT(0, "unrecognised property %s", p.name);
            }
        }

        this->m_typeName = typeName;
    }
Ejemplo n.º 14
0
bool zmq::stream_engine_t::init_properties (properties_t &properties_)
{
    if (_peer_address.empty ())
        return false;
    properties_.ZMQ_MAP_INSERT_OR_EMPLACE (
      std::string (ZMQ_MSG_PROPERTY_PEER_ADDRESS), _peer_address);

    //  Private property to support deprecated SRCFD
    std::ostringstream stream;
    stream << static_cast<int> (_s);
    std::string fd_string = stream.str ();
    properties_.ZMQ_MAP_INSERT_OR_EMPLACE (std::string ("__fd"),
                                           ZMQ_MOVE (fd_string));
    return true;
}
Ejemplo n.º 15
0
    bool BehaviorNode::load_property_pars(properties_t& properties, rapidxml::xml_node<>* c, int version, const char* agentType)
    {
        if (StringUtils::StrEqual(c->name(), kStrProperty))
        {
            if (rapidxml::xml_attribute<>* attr = c->first_attribute())
            {
                //std::cout << attr->name() << ":" << attr->value() << std::endl;
                const char* pPropertyName = attr->name();
                const char* pPropertyValue = attr->value();
                properties.push_back(property_t(pPropertyName, pPropertyValue));
            }

            return true;

        }
        else if (StringUtils::StrEqual(c->name(), kStrPars))
        {
            rapidxml::xml_node<>* children = c->first_node();

            if (children != NULL)
            {
                for (rapidxml::xml_node<>* child = children; child; child = child->next_sibling())
                {
                    if (StringUtils::StrEqual(child->name(), kStrPar))
                    {
                        this->load_par(version, agentType, child);
                    }
                }
            }

            return true;
        }

        return false;
    }
Ejemplo n.º 16
0
    void DecoratorWeight::load(int version, const char* agentType, const properties_t& properties)
    {
        super::load(version, agentType, properties);

        for (propertie_const_iterator_t it = properties.begin(); it != properties.end(); ++it)
        {
            const property_t& p = (*it);

            if (strcmp(p.name, "Weight") == 0)
            {
                behaviac::string typeName;
                behaviac::string propertyName;
                this->m_weight_var = Condition::LoadRight(p.value, typeName);
            }
        }
    }
Ejemplo n.º 17
0
    void SelectorProbability::load(int version, const char* agentType, const properties_t& properties) {
        super::load(version, agentType, properties);

        for (propertie_const_iterator_t it = properties.begin(); it != properties.end(); ++it) {
            const property_t& p = (*it);

			if (StringUtils::StringEqual(p.name, "RandomGenerator")) {
                if (p.value[0] != '\0') {
                    this->m_method = AgentMeta::ParseMethod(p.value);
                }//if (p.value[0] != '\0')

            } else {
                //BEHAVIAC_ASSERT(0, "unrecognised property %s", p.name);
            }
        }
    }
Ejemplo n.º 18
0
    void DecoratorIterator::load(int version, const char*  agentType, const properties_t& properties)
    {
        super::load(version, agentType, properties);

        behaviac::string typeName;
        behaviac::string propertyName;

        for (propertie_const_iterator_t p = properties.begin(); p != properties.end(); ++p)
        {
            if (strcmp(p->name, "Opl") == 0)
            {
                behaviac::string str(p->value);
                size_t pParenthesis = str.find_first_of('(');

				if (pParenthesis == (size_t)-1)
                {
                    this->m_opl = Condition::LoadLeft(p->value);

                }
                else
                {
                    BEHAVIAC_ASSERT(false);
                }
            }
            else if (strcmp(p->name, "Opr") == 0)
            {
                behaviac::string str(p->value);
                size_t pParenthesis = str.find_first_of('(');

				if (pParenthesis == (size_t)-1)
                {
                    this->m_opr = Condition::LoadRight(p->value, typeName);

                }
                else
                {
                    //method
                    this->m_opr_m = Action::LoadMethod(p->value);
                }
            }
            else
            {
                //BEHAVIAC_ASSERT(0, "unrecognised property %s", p->name);
            }
        }
    }
Ejemplo n.º 19
0
void __strace(const properties_t& properties, const char* str, ...)
{
  va_list vl;
  va_start(vl,str);
  if(properties.get_int("appserver.strace"))
    vprintf(str,vl);
  va_end(vl);
}
Ejemplo n.º 20
0
    void DecoratorLoop::load(int version, const char* agentType, const properties_t& properties) {
        DecoratorCount::load(version, agentType, properties);

        for (propertie_const_iterator_t it = properties.begin(); it != properties.end(); ++it) {
            const property_t& p = (*it);

            if (StringUtils::StringEqual(p.name, "DoneWithinFrame")) {
                if (p.value[0] != '\0') {
                    if (StringUtils::StringEqual(p.value, "true")) {
                        this->m_bDoneWithinFrame = true;
                    }
                }//if (p.value[0] != '\0')
            } else {
                //BEHAVIAC_ASSERT(0, "unrecognised property %s", p.name);
            }
        }

    }
Ejemplo n.º 21
0
    void Task::load(int version, const char* agentType, const properties_t& properties) {
        super::load(version, agentType, properties);

        //for (propertie_const_iterator_t it = properties.begin(); it != properties.end(); ++it)
        for (propertie_const_iterator_t it = properties.begin(); it != properties.end(); ++it) {
            const property_t p = *it;

            if (StringUtils::StringEqual(p.name, "Prototype")) {
                if (!StringUtils::IsNullOrEmpty(p.value)) {
                    this->m_task = AgentMeta::ParseMethod(p.value);
                }//if (p.value[0] != '\0')

            } else if (StringUtils::StringEqual(p.name, "IsHTN")) {
                if (StringUtils::StringEqual(p.value, "true")) {
                    this->m_bHTN = true;
                }
            }
        }
    }
Ejemplo n.º 22
0
    void DecoratorLoopUntil::load(int version, const char* agentType, const properties_t& properties)
    {
        super::load(version, agentType, properties);

        for (propertie_const_iterator_t it = properties.begin(); it != properties.end(); ++it)
        {
            const property_t& p = (*it);

            if (strcmp(p.name, "Until") == 0)
            {
                if (string_icmp(p.value, "true") == 0)
                {
                    this->m_until = true;

                }
                else if (string_icmp(p.value, "false") == 0)
                {
                    this->m_until = false;
                }
            }
        }
    }
Ejemplo n.º 23
0
    /**
    handle the Assignment property

    */
    void Assignment::load(int version, const char* agentType, const properties_t& properties)
    {
        super::load(version, agentType, properties);

        behaviac::string propertyName;

        for (propertie_const_iterator_t it = properties.begin(); it != properties.end(); ++it)
        {
            const property_t& p = (*it);

            if (strcmp(p.name, "Opl") == 0)
            {
                this->m_opl = Condition::LoadLeft(p.value);

            }
            else if (strcmp(p.name, "Opr") == 0)
            {
                const char* pParenthesis = strchr(p.value, '(');

                if (pParenthesis == 0)
                {
                    behaviac::string typeName;
                    behaviac::string	propertyName;
                    this->m_opr = Condition::LoadRight(p.value, typeName);

                }
                else
                {
                    //method
                    this->m_opr_m = Action::LoadMethod(p.value);
                }

            }
            else
            {
                //BEHAVIAC_ASSERT(0, "unrecognised property %s", p.name);
            }
        }
    }
Ejemplo n.º 24
0
void CompositeStochastic::load(int version, const char* agentType, const properties_t& properties)
{
    super::load(version, agentType, properties);

    for (propertie_const_iterator_t it = properties.begin(); it != properties.end(); ++it)
    {
        const property_t& p = (*it);

        if (strcmp(p.name, "RandomGenerator") == 0)
        {
            if (p.value[0] != '\0')
            {
                this->m_method = Action::LoadMethod(p.value);
            }//if (p.value[0] != '\0')

        }
        else
        {
            //BEHAVIAC_ASSERT(0, "unrecognised property %s", p.name);
        }
    }
}
Ejemplo n.º 25
0
    bool Effector::EffectorConfig::load(const properties_t& properties)
    {
        bool loaded = ActionConfig::load(properties);

        for (propertie_const_iterator_t p = properties.begin(); p != properties.end(); ++p)
        {
            behaviac::string p_value(p->value);
            behaviac::string p_name(p->name);

            if (p_name == "Phase")
            {
                if (p_value == "Success")
                {
                    this->m_phase = E_SUCCESS;

                }
                else if (p_value == "Failure")
                {
                    this->m_phase = E_FAILURE;

                }
                else if (p_value == "Both")
                {
                    this->m_phase = E_BOTH;

                }
                else
                {
                    BEHAVIAC_ASSERT(false);
                }

                break;
            }
        }

        return loaded;
    }
Ejemplo n.º 26
0
    void DecoratorNode::load(int version, const char* agentType, const properties_t& properties)
    {
        super::load(version, agentType, properties);

        for (propertie_const_iterator_t it = properties.begin(); it != properties.end(); ++it)
        {
            const property_t& p = (*it);

            if (StringUtils::StrEqual(p.name, "DecorateWhenChildEnds"))
            {
                if (p.value[0] != '\0')
                {
                    if (StringUtils::StrEqual(p.value, "true"))
                    {
                        this->m_bDecorateWhenChildEnds = true;
                    }
                }//if (p.value[0] != '\0')
            }
            else
            {
                //BEHAVIAC_ASSERT(0, "unrecognised property %s", p.name);
            }
        }
    }
Ejemplo n.º 27
0
    void BehaviorTree::load(int version, const char* agentType, const properties_t& properties)
    {
        super::load(version, agentType, properties);

        if (properties.size() > 0)
        {
            for (propertie_const_iterator_t it = properties.begin(); it != properties.end(); it++)
            {
                const property_t& p = (*it);

                if (StringUtils::StrEqual(p.name, "Domains"))
                {
                    m_domains = p.value;

                }
                else if (StringUtils::StrEqual(p.name, "DescriptorRefs"))
                {
                    StringUtils::FromString(p.value, this->m_descriptorRefs);

                    for (size_t i = 0; i < this->m_descriptorRefs.size(); ++i)
                    {
                        Descriptor_t& d = this->m_descriptorRefs[i];

                        if (d.Descriptor != NULL)
                        {
                            d.Descriptor->SetDefaultValue(d.Reference);
                        }
                    }
                }
                else
                {
                    //BEHAVIAC_ASSERT(0, "unrecognised property %s", p.name);
                }
            }
        }
    }
Ejemplo n.º 28
0
bool zmq::stream_engine_t::init_properties (properties_t & properties) {
    if (peer_address.empty()) return false;
    properties.insert (std::make_pair("Peer-Address", peer_address));
    return true;
}
Ejemplo n.º 29
0
int main(int argc, const char* argv[])
{
	properties.parse_args(argc, argv);

	stldb::timer_configuration config;
	config.enabled_percent = properties.getProperty("timing_percent", 0.0);
	config.report_interval_seconds = properties.getProperty("report_freq", 60);
	config.reset_after_print = properties.getProperty("report_reset", true);
	stldb::timer::configure( config );
	stldb::tracing::set_trace_level(stldb::fine_e);

	const int thread_count = properties.getProperty("threads", 4);
	const int loopsize = properties.getProperty("loopsize", 100);
	const int ops_per_txn = properties.getProperty("ops_per_txn", 10);

	g_db_dir = properties.getProperty<std::string>("rootdir", std::string("."));
	g_checkpoint_dir = g_db_dir + "/checkpoint";
	g_log_dir = g_db_dir + "/log";

	g_num_db = properties.getProperty("databases", 4);
	g_maps_per_db = properties.getProperty("maps_per_db", 4);
	g_max_key = properties.getProperty("max_key", 10000);
	g_avg_val_length = properties.getProperty("avg_val_length", 1000);
	g_max_wait = boost::posix_time::millisec(properties.getProperty("max_wait", 10000));
	g_checkpoint_interval = boost::posix_time::millisec(properties.getProperty("checkpoint_interval", 0));
	g_invalidation_interval = boost::posix_time::millisec(properties.getProperty("invalidation_interval", 0));

	// The loop that the running threads will execute
	test_loop loop(loopsize);
	CRUD_transaction main_op(ops_per_txn);
	loop.add( &main_op, 100 );

	// Start the threads which are going to run operations:
	boost::thread **workers = new boost::thread *[thread_count];
	for (int i=0; i<thread_count; i++) {
		workers[i] = new boost::thread( loop );
	}
	// start a thread which does periodic checkpointing
	boost::thread *checkpointor = NULL, *invalidator = NULL;
	if ( g_checkpoint_interval.seconds() > 0 ) {
		checkpointor = new boost::thread( checkpoint_operation(g_checkpoint_interval.seconds()) );
	}
	if ( g_invalidation_interval.seconds() > 0 ) {
		// start a thread which does periodic invalidation, forcing recovery to be done
		invalidator = new boost::thread( set_invalid_operation(g_invalidation_interval.seconds()) );
	}

	// Support the option of writing to an indicator file once all databses have been opened,
	// confirming to watching processes/scripts that database open/recovery has finished.
	std::string indicator_filename = properties.getProperty<std::string>("indicator_filename", std::string());
	if (!indicator_filename.empty()) {
		for (int i=0; i<g_num_db; i++) {
			shared_lock<boost::shared_mutex> lock;
			getDatabase(i, lock);
		}
		std::ofstream indf(indicator_filename.c_str());
	}
	
	// now await their completion
	for (int i=0; i<thread_count; i++) {
		workers[i]->join();
		delete workers[i];
	}

	// close the databases
	for (int i=0; i<g_num_db; i++) {
		closeDatabase(i);
	}

	// final print timing stats (if requested)
	if (config.enabled_percent > 0.0)
		stldb::time_tracked::print(std::cout, true);

	return 0;
}
Ejemplo n.º 30
0
bool AttachAction::ActionConfig::load(const properties_t& properties)
{
    string propertyName = "";
    string comparatorName = "";

    for (propertie_const_iterator_t it = properties.begin(); it != properties.end(); ++it)
    {
        property_t p = *it;
        behaviac::string p_name(p.name);
        behaviac::string p_value(p.value);

        if (p_name == "Mode")
        {
            if (StringUtils::StrEqual(p.value, "Condition"))
            {
                this->m_mode = TM_Condition;
            }
            else if (StringUtils::StrEqual(p.value, "Success"))
            {
                this->m_mode = TM_Success;
            }
            else if (StringUtils::StrEqual(p.value, "Failure"))
            {
                this->m_mode = TM_Failure;
            }
            else if (StringUtils::StrEqual(p.value, "End"))
            {
                this->m_mode = TM_End;
            }
        }
        else if (p_name == "Opl")
        {
            if (StringUtils::IsValidString(p.value))
            {
                size_t pParenthesis = p_value.find_first_of('(');

                if (pParenthesis == (size_t)-1)
                {
                    this->m_opl = Condition::LoadRight(p.value, this->m_typeName);
                }
                else
                {
                    this->m_opl_m = Action::LoadMethod(p.value);

                    if (this->m_opl_m)
                    {
                        this->m_opl_m->GetReturnTypeName(this->m_typeName);
                    }
                }
            }
        }
        else if (p_name == "Opr1")
        {
            if (StringUtils::IsValidString(p.value))
            {
                size_t pParenthesis = p_value.find_first_of('(');

                if (pParenthesis == (size_t)-1)
                {
                    this->m_opr1 = Condition::LoadRight(p.value, this->m_typeName);
                }
                else
                {
                    this->m_opr1_m = Action::LoadMethod(p.value);

                    if (this->m_opr1_m)
                    {
                        this->m_opr1_m->GetReturnTypeName(this->m_typeName);
                    }
                }
            }
        }
        else if (p_name == "Operator")
        {
            comparatorName = p_value;

            if (p_value == "Invalid")
            {
                this->m_operator = E_INVALID;
            }
            else if (p_value == "Assign")
            {
                this->m_operator = E_ASSIGN;
            }
            else if (p_value == "Add")
            {
                this->m_operator = E_ADD;
            }
            else if (p_value == "Sub")
            {
                this->m_operator = E_SUB;
            }
            else if (p_value == "Mul")
            {
                this->m_operator = E_MUL;
            }
            else if (p_value == "Div")
            {
                this->m_operator = E_DIV;
            }
            else if (p_value == "Equal")
            {
                this->m_operator = E_EQUAL;
            }
            else if (p_value == "NotEqual")
            {
                this->m_operator = E_NOTEQUAL;
            }
            else if (p_value == "Greater")
            {
                this->m_operator = E_GREATER;
            }
            else if (p_value == "Less")
            {
                this->m_operator = E_LESS;
            }
            else if (p_value == "GreaterEqual")
            {
                this->m_operator = E_GREATEREQUAL;
            }
            else if (p_value == "LessEqual")
            {
                this->m_operator = E_LESSEQUAL;
            }
        }
        else if (p_name == "Opr2")
        {
            if (StringUtils::IsValidString(p.value))
            {
                size_t pParenthesis = p_value.find_first_of('(');

                if (pParenthesis == (size_t)-1)
                {
                    this->m_opr2 = Condition::LoadRight(p.value, this->m_typeName);
                }
                else
                {
                    this->m_opr2_m = Action::LoadMethod(p.value);

                    if (this->m_opr2_m)
                    {
                        this->m_opr2_m->GetReturnTypeName(this->m_typeName);
                    }
                }
            }
        }
        else
        {
            //BEHAVIAC_ASSERT(0, "unrecognised property %s", p.name);
        }
    }

    // compare
    if (this->m_operator >= E_EQUAL && this->m_operator <= E_LESSEQUAL)
    {
        if (comparatorName.length() > 0 && (this->m_opl != NULL || this->m_opl_m != NULL) &&
                (this->m_opr2 != NULL || this->m_opr2_m != NULL))
        {
            this->m_comparator = Condition::Create(this->m_typeName.c_str(), comparatorName.c_str(), this->m_opl, this->m_opl_m, this->m_opr2, this->m_opr2_m);
        }
    }

    return this->m_opl != NULL;
}