GPStreamADF::GPStreamADF(const GPTreeNode* n, const GPFunctionDataBase* base)
{
    mInputTypes.clear();
    mOutputTypes.clear();
    auto children = n->getChildren();
    GPASSERT(3 == children.size());
    mSources.clear();
    /*Source*/
    std::map<std::string, Point*> sp_map;
    {
        auto source = children[0];
        GPASSERT(source->name() == "Source");
        for (auto types : source->getChildren())
        {
            auto source_name = types->name();
            auto type_name = types->attr();
            auto spoint = new SP(base->vQueryType(type_name));
            mSources.push_back(spoint);
            sp_map.insert(std::make_pair(source_name, spoint));
        }
    }
    std::map<std::string, GPPtr<Point>> cp_map;
    /*ComputePoints*/
    {
        auto computepoints_info = children[1];
        GPASSERT(computepoints_info->name() == "ComputePoint");
        /*Collect all points firstly*/
        for (auto compute_info : computepoints_info->getChildren())
        {
            auto function = base->vQueryFunction(GPStringHelper::cleanString(compute_info->attr()));
            if (NULL == function)
            {
                FUNC_PRINT_ALL(compute_info->attr().c_str(), s);
            }
            GPASSERT(NULL!=function);
            std::vector<bool> flags;
            for (auto info : compute_info->getChildren())
            {
                if (info->name() == "InputFlag")
                {
                    auto attrs = GPStringHelper::divideString(info->attr());
                    for (auto attr : attrs)
                    {
                        if (attr == "False")
                        {
                            flags.push_back(false);
                        }
                        else if (attr == "True")
                        {
                            flags.push_back(true);
                        }
                        else
                        {
                            FUNC_PRINT_ALL(attr.c_str(), s);
                            GPASSERT(0);
                        }
                    }
                }
            }
            if (flags.size() == 0)
            {
                for (auto inp : function->inputType)
                {
                    GPASSERT(NULL!=inp);//Make Xcode check happy
                    flags.push_back(false);
                }
            }
            auto node = new CP(new GPComputePoint(function, flags));
            mFunctions.push_back(node);
            cp_map.insert(std::make_pair(compute_info->name(), node));
        }
        
        /*Now Connect*/
        for (auto compute_info : computepoints_info->getChildren())
        {
            auto function = base->vQueryFunction(GPStringHelper::cleanString(compute_info->attr()));
            auto this_node = cp_map.find(compute_info->name())->second;
            for (auto info : compute_info->getChildren())
            {
                if (info->name() == "Input")
                {
                    auto node_names = GPStringHelper::divideString(info->attr());
                    for (auto name : node_names)
                    {
                        auto s_iter = sp_map.find(name);
                        if (s_iter == sp_map.end())
                        {
                            continue;
                        }
                        s_iter->second->connectOutput(this_node);
                        this_node->connectInput(s_iter->second);
                    }
                }
                if (info->name() == "Output")
                {
                    auto node_names = GPStringHelper::divideString(info->attr());
                    GPASSERT(function->outputType.size() == node_names.size());
                    auto n = function->outputType.size();
                    for (size_t i=0; i<n; ++i)
                    {
                        auto name = node_names[i];
                        auto cp_iter = cp_map.find(name);
                        if (cp_iter!=cp_map.end())
                        {
                            auto output = cp_iter->second;
                            this_node->connectOutput(output);
                            output->connectInput(this_node.get());
                            continue;
                        }
                        auto dst = new DP(function->outputType[i]);
                        mDest.push_back(dst);
                        dst->connectInput(this_node.get());
                        this_node->connectOutput(dst);
                        dst->addRef();
                    }
                }
            }
        }
    }
    /*Load Status*/
    {
        auto status_tn = children[2];
        GPASSERT(status_tn->name() == "Status");
        auto status_values = GPStringHelper::divideString(status_tn->attr());
        if (status_values.size() > 0)
        {
            GPASSERT(status_values.size() == this->vMap(NULL));
            GPPtr<GPParameter> para = new GPParameter((int)(status_values.size()));
            for (int i=0; i<status_values.size(); ++i)
            {
                std::istringstream number(status_values[i]);
                number >> para->attach()[i];
            }
            this->vMap(para.get());
        }
        
    }
Пример #2
0
void Renderbuffer::onAttach(const Context *context)
{
    addRef();
}
Пример #3
0
 void addWeakRef(const void* id) {
     addRef(&mWeakRefs, id, mWeak);
 }
Пример #4
0
 void addStrongRef(const void* id) {
     //ALOGD_IF(mTrackEnabled,
     //        "addStrongRef: RefBase=%p, id=%p", mBase, id);
     addRef(&mStrongRefs, id, mStrong);
 }
Пример #5
0
void HttpOpRequest::stageFromReady(HttpService * service)
{
	addRef();
	service->getTransport().addOp(this);		// transfers refcount
}
Пример #6
0
void HttpOpRequest::stageFromRequest(HttpService * service)
{
	addRef();
	service->getPolicy().addOp(this);			// transfers refcount
}
Пример #7
0
//==================================================================
VarLink::VarLink( const VarLink &from )
{
	mpNode	= from.mpNode;
	mVarIdx	= from.mVarIdx;
	addRef();
}