コード例 #1
0
ファイル: Namespace.cpp プロジェクト: P-i-N/metagen
Node* Namespace::ForwardDeclareAlongPath(const tNodePath& path)
{
  if (path.empty())
    return nullptr;

  if (path[0]->GetNodeType() != NodeType::Namespace || path[0]->GetName() != GetName())
    return nullptr;

  Namespace *parent = this;
  for (size_t i = 1, S = path.size(); i < S; ++i)
  {
    auto p = path[i];

    if (p->GetNodeType() == NodeType::Namespace)
      parent = GetOrCreateNamespace(p->GetName());
    else if (p->GetNodeType() == NodeType::Class)
      parent = GetOrCreateClass(p->GetName());
    else if (p->GetNodeType() == NodeType::Type)
    {
      if (i == S - 1)
        return GetOrCreateType((static_cast<const Type *>(p))->GetPrimitive(), p->GetName());
      else
        return nullptr;
    }
  }

  return parent;
}
コード例 #2
0
bool SP_Node_CH::DataRespondHandler_SN(SP_Msg& inMsg)
{	
	//DATA MESSAGE, FROM SENSOR NODES
	if(!(
	this->state == SP_CommState::CONNECTED &&
	inMsg.type == SP_MsgType::DATA && 
	inMsg.fromNodeType == SP_NodeType::SN))
		return false;
	
	#ifdef SMARTPARK_SERIAL_DEBUG
	Serial.print(F("[INFO]: Parked="));
	Serial.println(static_cast<uint8_t>(inMsg.data[0]) == 1);
	#endif
	
	//Take data and add to table
	bool parked = static_cast<uint8_t>(inMsg.data[0]) == 1;
	AddOrModifyEventData(inMsg.from, parked);
	
	//Respond with an ACK
	SP_Msg* existingMsg = GetFirstOutMsgOfType(SP_MsgType::ACK);
	if(existingMsg == 0)
	{
		//ACKnowledge their message
		SP_Msg* outMsg = new SP_Msg();
		outMsg->reliable = false;
		outMsg->to = inMsg.from;
		outMsg->from = this->addr;
		outMsg->fromNodeType = GetNodeType();
		outMsg->type = SP_MsgType::ACK;
		outMsg->dataLen = 0;
		outMsg->data = 0;
		this->PendMsg(outMsg);
	}
	return true;
}
コード例 #3
0
STDMETHODIMP CMaxMaterialCollection::IsSelectionValid(VARIANT_BOOL* vResult)
{
	Interface* ip = GetCOREInterface();

	*vResult = VARIANT_FALSE;

	/*
	if(ip->GetSelNodeCount())
		*vResult = VARIANT_TRUE;
		*/

    int n = 0;
	int count = ip->GetSelNodeCount();
	INode *pNode;
    for (int i=0; i<count; i++) {
		pNode = ip->GetSelNode(i);
		if(pNode == NULL)
			continue;
        SClass_ID id = GetNodeType(pNode);
        if (id==SHAPE_CLASS_ID) n++;
        else if (id==GEOMOBJECT_CLASS_ID) {
            if (!pNode->IsTarget()) n++;
            }
        }
 
	if(n>0)
		*vResult = VARIANT_TRUE;


	return S_OK;
}
コード例 #4
0
bool SP_Node_CH::DataRespondHandler_CH(SP_Msg& inMsg)
{
	//DATA MESSAGE, FROM CLUSTER HEAD NODES
	if(!(
	this->state == SP_CommState::CONNECTED &&
	inMsg.type == SP_MsgType::DATA && 
	inMsg.fromNodeType == SP_NodeType::CH))
		return false;
	
	//Get the data from the message
	uint8_t len = getSP_EventDataArrLenFromStr(inMsg.data);
	SP_EventData** datas = new SP_EventData*[len];
	len = parseSP_EventDataArrStr(inMsg.data, datas, len); //Returns actual len
	
	//Take data and add to table
	for(int i=0; i<len; ++i)
		AddOrModifyEventData(datas[i]->from, datas[i]->parked);
	
	//Respond with an ACK
	SP_Msg* existingMsg = GetFirstOutMsgOfType(SP_MsgType::ACK);
	if(existingMsg == 0)
	{
		//ACKnowledge their message
		SP_Msg* outMsg = new SP_Msg();
		outMsg->reliable = false;
		outMsg->to = inMsg.from;
		outMsg->from = this->addr;
		outMsg->fromNodeType = GetNodeType();
		outMsg->type = SP_MsgType::ACK;
		outMsg->dataLen = 0;
		outMsg->data = 0;
		this->PendMsg(outMsg);
	}
	return true;
}
コード例 #5
0
ファイル: NiKFuncs5.c プロジェクト: punktniklas/NiKom
int bytnodtyp(void) {
	int going=TRUE,nr,x;
	struct NodeType *nt=NULL;
	puttekn("\n\n\rVilken nodtyp vill du ha som förinställd?\n\n\r",-1);
	puttekn(" 0: Ingen, jag vill bli tillfrågad vid inloggning.\n\r",-1);
	for(x=0; x<MAXNODETYPES; x++) {
		if(Servermem->nodetypes[x].nummer==0) break;
		sprintf(outbuffer,"%2d: %s\n\r",Servermem->nodetypes[x].nummer,Servermem->nodetypes[x].desc);
		putstring(outbuffer,-1,0);
	}
	while(going) {
		putstring("\n\rVal: ",-1,0);
		if(getstring(EKO,2,NULL)) return(1);
		nr = atoi(inmat);
		if(nr<0) putstring("\n\rDu måste ange ett positivt heltal.\n\r",-1,0);
		else if(nr==0) going=FALSE;
		else if(!(nt=GetNodeType(atoi(inmat)))) putstring("\n\rFinns ingen sådan nodtyp.\n\r",-1,0);
		else going=FALSE;
	}
	if(!nt) {
		Servermem->inne[nodnr].shell=0;
		puttekn("\n\n\rDu har nu ingen förinställd nodtyp.\n\r",-1);
	} else {
		Servermem->inne[nodnr].shell = nt->nummer;
		puttekn("\n\n\rDin förinställda nodtyp är nu:\n\r",-1);
		puttekn(nt->desc,-1);
		puttekn("\n\n\r",-1);
	}
	return(0);
}
コード例 #6
0
bool ProjectFileParser::ReadItemGroup(rapidxml::xml_node<>* node)
{
    std::string label = GetAttributeValue(node,"Label");
    if (label == "ProjectConfigurations")
        return ReadProjectConfigurations(node);

    rapidxml::xml_node<>* child = node->first_node();
    while (child)
    {
        switch (GetNodeType(child))
        {
            case eClCompile:
                AddSourceFile(child);
                break;
            case eClInclude:
                AddIncludeFile(child);
                break;
            case eResourceCompile:
                AddResourceFile(child);
                break;
            case eCustomBuild:
                AddCustomBuildFile(child);
                break;
            case eNone:
                break;
            case eProjectReference:
                AddProjectReference(child);
                break;
            default:
                break;
        }
        child = child->next_sibling();
    }
    return true;
}
コード例 #7
0
ファイル: json_over_uttp.cpp プロジェクト: swuecho/igblast
string CJsonNode::Repr(TReprFlags flags) const
{
    CNcbiOstrstream oss;

    switch (GetNodeType()) {
    case CJsonNode::eObject:
        if (flags & fOmitOutermostBrackets)
            s_Repr_Object(oss, *this);
        else {
            oss << '{';
            s_Repr_Object(oss, *this);
            oss << '}';
        }
        break;
    case CJsonNode::eArray:
        if (flags & fOmitOutermostBrackets)
            s_Repr_Array(oss, *this);
        else {
            oss << '[';
            s_Repr_Array(oss, *this);
            oss << ']';
        }
        break;
    case CJsonNode::eString:
        if (flags & fVerbatimIfString)
            return (static_cast<const SJsonStringNodeImpl*>(
                    m_Impl.GetPointerOrNull())->m_String);
        /* FALL THROUGH */
    default:
        s_Repr_Value(oss, *this);
    }

    return CNcbiOstrstreamToString(oss);
}
コード例 #8
0
MovieTexture::MovieTexture() : X3DTexture2DNode(GetNodeType()),
	m_url(new MFString(this)),
	m_repeatS(new SFBool(this, true)),
	m_repeatT(new SFBool(this, true))
{
//	m_texName = 0;
	m_status = 0;
}
コード例 #9
0
Transform::Transform() : X3DGroupingNode(GetNodeType()),
	m_center(new SFVec3f(get_centerFieldDef(), this)),
	m_rotation(new SFRotation(get_rotationFieldDef(), this)),
	m_scale(new SFVec3f(get_scaleFieldDef(), this)),
	m_scaleOrientation(new SFRotation(get_scaleOrientationFieldDef(), this)),
	m_translation(new SFVec3f(get_translationFieldDef(), this))
{
}
コード例 #10
0
Material::Material() : X3DMaterialNode(GetNodeType()),

	m_ambientIntensity(new SFFloat(get_ambientIntensityFieldDef(), this)),
	m_diffuseColor(new SFColor(get_diffuseColorFieldDef(), this)),
	m_emissiveColor(new SFColor(get_emissiveColorFieldDef(), this)),
	m_shininess(new SFFloat(get_shininessFieldDef(), this)),
	m_specularColor(new SFColor(get_specularColorFieldDef(), this)),
	m_transparency(new SFFloat(get_transparencyFieldDef(), this))
{
}
コード例 #11
0
bool
ConfigManager::ReadTag(std::istream& in, std::string &tagName, NodeTypeEnum &tagType,
    int &tagLength, bool &tagIsReturnTag)
{
    // Read strings.
    stringVector sv = ReadStringVector(in, '>');

    std::string tagTypeStr("");
    tagName = "";
    tagType = INTERNAL_NODE;
    tagLength = 0;

    for(size_t i = 0; i < sv.size(); ++i)
    {
        std::string::size_type pos = sv[i].find('=') + 1;
        std::string token(sv[i].substr(0, pos));
        std::string tokenValue;

        if(pos != std::string::npos && token.size() > 0)
            tokenValue = sv[i].substr(pos + 1, sv[i].size() - pos - 2);

        if(sv[i][0] == '/')
        {
            tagIsReturnTag = true;
            return true;
        }
        else if(token == "type=")
        {
            tagTypeStr = tokenValue;
        }
        else if(token == "name=")
        {
            tagName = tokenValue;
        }
        else if(token == "length=")
        {
            int len;
            if(sscanf(tokenValue.c_str(), "%d", &len) == 1)
            {
                tagLength = (len > 0) ? len : tagLength;
            }
        }
        else if(token == "childObjects=")
        {
            // Skip this tag, it is obsolete.
        }
        else
            tagTypeStr = sv[i];
    }

    // Get the NodeTypeEnum from the tag's type name.
    tagType = GetNodeType(tagTypeStr.c_str());

    return sv.size() > 0;    
}
コード例 #12
0
Sound::Sound() : X3DSoundNode(GetNodeType()),

	m_direction(new SFVec3f(get_directionFieldDef(), this, Vec3f(0.0f, 0.0f, 1.0f))),
	m_intensity(new SFFloat(get_intensityFieldDef(), this, 1.0f)),
	m_maxBack(new SFFloat(get_maxBackFieldDef(), this, 10)),
	m_maxFront(new SFFloat(get_maxFrontFieldDef(), this, 10)),
	m_minBack(new SFFloat(get_minBackFieldDef(), this, 1)),
	m_minFront(new SFFloat(get_minFrontFieldDef(), this, 1)),

	m_bPlaying(false)
{
}
コード例 #13
0
static rc_t CC NodeDataInit(NodeData* data, const KXMLNode* node,
    const char* parentName, uint32_t idx)
{
    rc_t rc = 0;

    assert(node && parentName && data);

    memset(data, 0, sizeof *data);

    rc = KXMLNodeGetName(node, &data->nodeName);
/*  if (rc != 0) {
        PLOGERR(klogErr, (klogErr, rc,
            "while calling KXMLNodeGetName($(parent)[$(i)]",
            "parent=%s,i=%d", parentName, idx));
    }*/

    if (rc == 0
        && data->nodeName && !strcmp(data->nodeName, "symlink"))
    {
        rc = KXMLNodeReadCStr(node, &data->nodeValue, NULL);
/*      if (rc != 0) {
            PLOGERR(klogErr, (klogErr, rc,
                "while calling KXMLNodeReadCStr($(name))",
                "name=%s", data->nodeName));
        }*/
    }

    if (rc == 0) {
        rc = NodeDataReadAttribs(data, node, parentName, idx);
    }

    if (rc == 0) {
        data->nodeType = GetNodeType(data->nodeName);

        if (data->md5) {
            if (strlen(data->md5) != 32) {
                rc = RC(rcFS, rcXmlDoc, rcReading, rcFormat, rcInvalid);
/*              PLOGERR(klogErr, (klogErr, rc,
                    "md5sum '$(md5)'", "md5=%s", data->md5));*/
            }
            else {
                rc = MD5SumExtract(data->md5, data->digest);
            }
        }
    }

    if (rc == 0) {
        rc = StrToKTime(data->mtime, &data->tMtime);
    }

    return rc;
}
コード例 #14
0
Box::Box() : X3DGeometryNode(GetNodeType()), m_size(new SFVec3f(get_sizeFieldDef(), this, Vec3f(2,2,2)))
{
//	m_vertexBuffer = NULL;

//	m_size = NULL;

// Cache pointers to relevant fields
//	m_size = static_cast<SFVec3f*>(getField(WSTR("size")));
	ASSERT(m_size);

// Set defaults
//	m_size->m_value[0] = m_size->m_value[1] = m_size->m_value[2] = 2;
}
コード例 #15
0
std::auto_ptr<Project> ProjectFileParser::Parse(std::string file)
{
    std::auto_ptr<Project> ret;
    try
    {
        rapidxml::file<> xmlFile(file.c_str());
        rapidxml::xml_document<> doc;
        doc.parse<0>(xmlFile.data());
        rapidxml::xml_node<>* projNode = doc.first_node();
        if (projNode == NULL) return ret;
        if (std::string(projNode->name()) != "Project") return ret;

        ret.reset(new Project());
        m_project = ret.get();

        rapidxml::xml_node<>* node = projNode->first_node();
        while (node)
        {
            switch (GetNodeType(node))
            {
                case eItemGroup:
                    ReadItemGroup(node);
                    break;
                case ePropertyGroup:
                    ReadPropertyGroup(node);
                    break;
                case eImportGroup:
                    ReadImportGroup(node);
                    break;
                case eImport:
                    ReadImport(node);
                    break;
                case eItemDefinitionGroup:
                    ReadItemDefinitionGroup(node);
                    break;
                case eUnknown:
                    break;
                default:
                    // any node at this level should be handled
                    break;
            }
            node = node->next_sibling();
        }
    }
    catch (...)
    {
        ret.reset();
    }
    m_project = NULL;
    return ret;
}
コード例 #16
0
bool SP_Node_CH::ConnectedHandler(SP_Msg& inMsg)
{
	//Only respond to ADD messages directly to us
	if(!(
	inMsg.type == SP_MsgType::ADD))
		return false;
	
	bool shouldRespond = false;
	//Respond if we have an existing NEW out message and no neighbors
	SP_Msg* existingMsg = GetOutMsg(0);
	if(existingMsg != 0 && existingMsg->type == SP_MsgType::NEW && neighborCount == 0)
	{
		//Remove message
		RemoveFirstOutMsg();
		shouldRespond = true;
		
		//Add neighbor
		SP_Node::SP_Node_Info* newNeighbor = new SP_Node::SP_Node_Info();
		newNeighbor->addr = inMsg.from;
		newNeighbor->type = inMsg.fromNodeType;
		AddNeighbor(newNeighbor);
		
		state = SP_CommState::CONNECTED;
	}
	//Or if responding to node that's our upstream neighbor
	else if(neighbors[0] != 0 && neighbors[0]->addr == inMsg.from)
	{
		shouldRespond = true;
	}
	
	if(!shouldRespond) //Don't continue if no response
		return false;
		
	//Respond with ACK
	existingMsg = GetFirstOutMsgOfType(SP_MsgType::ACK);
	if(existingMsg == 0)
	{
		//Add new ACK if none exists
		SP_Msg* outMsg = new SP_Msg();
		outMsg->reliable = false;
		outMsg->to = inMsg.from;
		outMsg->from = this->addr;
		outMsg->fromNodeType = GetNodeType();
		outMsg->type = SP_MsgType::ACK;
		outMsg->dataLen = 0;
		outMsg->data = 0;
		//Set this message as pending
		this->PendMsg(outMsg);
	}
	return true;
}
コード例 #17
0
void XmlReader::Advance()
{
    do
    {
        int succ = xmlTextReaderRead(mImpl);
        if(succ == -1)
        {
            throw Exception("Couldn't read xml file ");
        }
        else if(succ == 0)
        {
            break;
        }
    }
    while(!IsSignificant(GetNodeType()));
}
コード例 #18
0
ファイル: DOMParserImpl.cpp プロジェクト: hfiguiere/exempi
	spIMetadata APICALL DOMParserImpl::Parse( const char * buffer, sizet bufferLength ) {
		auto node = ParseAsNode( buffer, bufferLength );
		if ( node ) {
			switch ( node->GetNodeType() ) {
			case INode::kNTSimple:
			case INode::kNTArray:
				{
					spIMetadata meta = IMetadata::CreateMetadata();
					meta->AppendNode( node );
					return meta;
				}
				break;

			case INode::kNTStructure:
				{
					pIMetadata meta( NULL );
					try {
						meta = node->GetInterfacePointer< IMetadata >();
					} catch ( spcIError err ) {
						meta = NULL;
					}
					if ( meta ) {
						return MakeUncheckedSharedPointer( meta, __FILE__, __LINE__ );
					} else {
						spIMetadata meta = IMetadata::CreateMetadata();
						meta->AppendNode( node );
						return meta;
					}
				}
				break;

			default:
				NOTIFY_ERROR( IError::kEDGeneral, kGECInternalFailure, "Unhandled situation occured", IError::kESOperationFatal, false, false );
			}
		}
		return spIMetadata();
	}
コード例 #19
0
void SP_Node_CH::HeldDataAction()
{
	if(!(
	dataHasChanged &&
	state == SP_CommState::CONNECTED))
		return;
	
	//Get a the string representing all the data
	uint8_t heldDataStrLen = getSP_EventDataArrStrLen(dataCount);
	char* heldDataStr = new char[heldDataStrLen];
	getSP_EventDataArrStr(data, dataCount, heldDataStr, heldDataStrLen);
	
	//Pend a message with all data
	SP_Msg* existingMsg = GetFirstOutMsgOfType(SP_MsgType::DATA);
	if(existingMsg == 0)
	{
		//Pend new message
		SP_Msg* outMsg = new SP_Msg();
		outMsg->reliable = true;
		outMsg->to = neighbors[0]->addr;
		outMsg->from = this->addr;
		outMsg->fromNodeType = GetNodeType();
		outMsg->type = SP_MsgType::DATA;
		outMsg->dataLen = heldDataStrLen;
		outMsg->data = heldDataStr;
		this->PendMsg(outMsg);
	}
	else
	{
		//Reuse existing message
		delete[] existingMsg->data; //Delete old buffer
		existingMsg->dataLen = heldDataStrLen; //Use new buffer
		existingMsg->data = heldDataStr;
	}
	
	dataHasChanged = false;
}
コード例 #20
0
bool SP_Node_CH::ConnectRespondHandler(SP_Msg& inMsg)
{
	if(!(
	this->state == SP_CommState::CONNECTED &&
	inMsg.type == SP_MsgType::NEW))
		return false;
	
	SP_Msg* existingMsg = GetFirstOutMsgOfType(SP_MsgType::ADD);
	if(existingMsg == 0)
	{
		//Add new ADD if none exists
		SP_Msg* outMsg = new SP_Msg();
		outMsg->reliable = true;
		outMsg->to = inMsg.from;
		outMsg->from = this->addr;
		outMsg->fromNodeType = GetNodeType();
		outMsg->type = SP_MsgType::ADD;
		outMsg->dataLen = 0;
		outMsg->data = 0;
		//Set this message as pending
		this->PendMsg(outMsg);
	}
	return true;
}
コード例 #21
0
Anchor::Anchor() : X3DGroupingNode(GetNodeType())
{
}
コード例 #22
0
/*
 *  ======== DSPNode_Delete ========
 *  Purpose:
 *      Delete all DSP-side and GPP-side resources for the node.
 */
DBAPI DSPNode_Delete(DSP_HNODE hNode)
{
	DSP_STATUS status = DSP_SOK;
	Trapped_Args tempStruct;
	BYTE *pVirtBase = NULL;
	struct DSP_BUFFERATTR bufAttr;
	struct CMM_OBJECT *hCmm;		/* shared memory mngr handle */
	struct CMM_INFO pInfo;		/* Used for virtual space allocation */
	DSP_NODETYPE nodeType;
	struct DSP_NODEATTR    nodeAttr;
#ifdef DEBUG_BRIDGE_PERF
	struct timeval tv_beg;
	struct timeval tv_end;
	struct timezone tz;
	int timeRetVal = 0;

	timeRetVal = getTimeStamp(&tv_beg);
#endif

	DEBUGMSG(DSPAPI_ZONE_FUNCTION, (TEXT("NODE: DSPNode_Delete:\r\n")));
	if (!hNode) {
		/* Invalid pointer */
		status = DSP_EHANDLE;
		DEBUGMSG(DSPAPI_ZONE_ERROR, (TEXT("NODE: DSPNode_Delete: "
					"hNode is Invalid Handle\r\n")));
		return status;
	}
	/* Get segment size.
	 >0 is SM segment. Get default SM Mgr*/
	tempStruct.ARGS_CMM_GETHANDLE.hProcessor = NULL;
	tempStruct.ARGS_CMM_GETHANDLE.phCmmMgr = &hCmm;
	status = DSPTRAP_Trap(&tempStruct, CMD_CMM_GETHANDLE_OFFSET);
	if (DSP_SUCCEEDED(status)) {
		/* Get SM segment info from CMM */
		tempStruct.ARGS_CMM_GETINFO.hCmmMgr = hCmm;
		tempStruct.ARGS_CMM_GETINFO.pCmmInfo = &pInfo;
		status = DSPTRAP_Trap(&tempStruct, CMD_CMM_GETINFO_OFFSET);
		if (DSP_FAILED(status)) {
			status = DSP_EFAIL;
			DEBUGMSG(DSPAPI_ZONE_ERROR,
				(TEXT("NODE: DSPNode_Delete:"
					" Failed to get SM segment\r\n")));
		} else
			status = DSP_SOK;

	} else {
		status = DSP_EFAIL;
		DEBUGMSG(DSPAPI_ZONE_ERROR, (TEXT("NODE: DSPNode_Delete: "
					"Failed to CMM handle\r\n")));
	}
	if (!DSP_SUCCEEDED(status)) {
		status = DSP_EBADSEGID;	/* no SM segments*/
		return status;
	}
    status = DSPNode_GetAttr(hNode, &nodeAttr, sizeof(nodeAttr));
	GetNodeType(hNode, &nodeType);
	if (nodeType != NODE_DEVICE) {
		/*segInfo index starts at 0.These checks may not be required*/
		if ((pInfo.segInfo[0].dwSegBasePa != 0) &&
		    (pInfo.segInfo[0].ulTotalSegSize) > 0) {
			/* get node translator's virtual address range
			   so we can free it */
			bufAttr.uAlignment = 0;
			bufAttr.uSegment = 1 | MEMRY_GETVIRTUALSEGID;
			DSPNode_AllocMsgBuf(hNode, 1, &bufAttr, &pVirtBase);
			/* Free virtual space */
			if (!pVirtBase)
				goto loop_end;

			if (munmap(pVirtBase,
					pInfo.segInfo[0].ulTotalSegSize)) {
				status = DSP_EFAIL;
			}
		}
	}
loop_end:
	if (DSP_SUCCEEDED(status)) {
		/* Set up the structure Call DSP Trap */
		tempStruct.ARGS_NODE_DELETE.hNode = hNode;
		status = DSPTRAP_Trap(&tempStruct, CMD_NODE_DELETE_OFFSET);
		/* Free any node heap memory */
		if (nodeAttr.inNodeAttrIn.pGPPVirtAddr) {
			DEBUGMSG(DSPAPI_ZONE_FUNCTION, (TEXT("DSPNodeDelete:"
					"Freeing Node heap addr \n")));
			free(nodeAttr.inNodeAttrIn.pGPPVirtAddr);
		}
	}
#ifdef DEBUG_BRIDGE_PERF
	timeRetVal = getTimeStamp(&tv_end);
	PrintStatistics(&tv_beg, &tv_end, "DSPNode_Delete", 0);
#endif

	return status;
}
コード例 #23
0
/*
 *  ======== DSPNode_Allocate ========
 *  Purpose:
 *      Allocate data structures for controlling and communicating
 *      with a node on a specific DSP processor..
 */
DBAPI DSPNode_Allocate(DSP_HPROCESSOR hProcessor,
		 IN CONST struct DSP_UUID *pNodeID,
		 IN CONST OPTIONAL struct DSP_CBDATA *pArgs,
		 IN OPTIONAL struct DSP_NODEATTRIN *pAttrIn,
		 OUT DSP_HNODE *phNode)
{
	DSP_STATUS status = DSP_SOK;
	Trapped_Args tempStruct;
	struct CMM_OBJECT *hCmm;		/* shared memory mngr handle */
	struct CMM_INFO pInfo;		/* Used for virtual space allocation */
	PVOID pVirtBase;
	struct DSP_BUFFERATTR bufAttr;
    DSP_NODETYPE nodeType;
    struct DSP_NDBPROPS    nodeProps;
    UINT            heapSize = 0;
    PVOID           pGPPVirtAddr = NULL;
    UINT            uProfileID;
	DEBUGMSG(DSPAPI_ZONE_FUNCTION, (TEXT("NODE: DSPNode_Allocate:\r\n")));
	if (!hProcessor) {
		status = DSP_EHANDLE;
		DEBUGMSG(DSPAPI_ZONE_ERROR,
			(TEXT("NODE: DSPNode_Allocate: "
				"hProcessor is Invalid \r\n")));
		goto func_cont;
	}
	if (!(pNodeID) || !(phNode)) {
		status = DSP_EPOINTER;
		DEBUGMSG(DSPAPI_ZONE_ERROR, (TEXT("NODE: DSPNode_Allocate: "
			"Invalid pointer in the Input\r\n")));
		goto func_cont;
	}
	/* First get the NODE properties, allocate, reserve
				memory for Node heap */
	if (pAttrIn) {
		status = DSPNode_GetUUIDProps(hProcessor, pNodeID, &nodeProps);
		pAttrIn->pGPPVirtAddr = NULL;
		if (DSP_SUCCEEDED(status)) {
			uProfileID = pAttrIn->uProfileID;
			DEBUGMSG(DSPAPI_ZONE_FUNCTION,
					("DSPNodeAllocate: User requested"
						  "node heap profile \n"));
			if (uProfileID < nodeProps.uCountProfiles)
				heapSize =
				nodeProps.aProfiles[uProfileID].ulHeapSize;
			if (heapSize) {
				/* allocate heap memory */
				/* Make heap size multiple of page size * */
				heapSize = PG_ALIGN_HIGH(heapSize, PG_SIZE_4K);
				/* align memory on cache line boundary * */
				pGPPVirtAddr = memalign(GEM_CACHE_LINE_SIZE,
							heapSize);
				DEBUGMSG(DSPAPI_ZONE_FUNCTION,
					("DSPNodeAllocate: Node heap memory"
							  "addr, size \n"));
				if ((pGPPVirtAddr == NULL))
					status = DSP_EMEMORY;
				pAttrIn->uHeapSize = heapSize;
				pAttrIn->pGPPVirtAddr = pGPPVirtAddr;
			}
		} else {
			DEBUGMSG(DSPAPI_ZONE_ERROR, (TEXT(
				"NODE:DSPNode_Allocate: Failed to get Node "
				"UUID properties \r\n")));
		}
	}
	if (DSP_SUCCEEDED(status)) {
		/* Set up the structure  Call DSP Trap */
		tempStruct.ARGS_NODE_ALLOCATE.hProcessor = hProcessor;
		tempStruct.ARGS_NODE_ALLOCATE.pNodeID =
						(struct DSP_UUID *)pNodeID;
		tempStruct.ARGS_NODE_ALLOCATE.pArgs =
						(struct DSP_CBDATA *)pArgs;
		tempStruct.ARGS_NODE_ALLOCATE.pAttrIn =
					(struct DSP_NODEATTRIN *)pAttrIn;
		tempStruct.ARGS_NODE_ALLOCATE.phNode = phNode;
		status = DSPTRAP_Trap(&tempStruct, CMD_NODE_ALLOCATE_OFFSET);
	}
func_cont:
	 /* If 1st SM segment is configured then allocate and map it to
		this process.*/
	if (!DSP_SUCCEEDED(status)) {
		if (pGPPVirtAddr)
			free(pGPPVirtAddr);
		return status;
	}
	tempStruct.ARGS_CMM_GETHANDLE.hProcessor = hProcessor;
	tempStruct.ARGS_CMM_GETHANDLE.phCmmMgr = &hCmm;
	status = DSPTRAP_Trap(&tempStruct, CMD_CMM_GETHANDLE_OFFSET);
	if (DSP_SUCCEEDED(status)) {
		/* Get SM segment info from CMM */
		tempStruct.ARGS_CMM_GETINFO.hCmmMgr = hCmm;
		tempStruct.ARGS_CMM_GETINFO.pCmmInfo = &pInfo;
		status = DSPTRAP_Trap(&tempStruct, CMD_CMM_GETINFO_OFFSET);
		if (DSP_FAILED(status)) {
			status = DSP_EFAIL;
			DEBUGMSG(DSPAPI_ZONE_ERROR, (TEXT(
			"NODE: DSPNode_Allocate: "
			"Failed to get SM segment\r\n")));
		} else
			status = DSP_SOK;

	} else {
		status = DSP_EFAIL;
		DEBUGMSG(DSPAPI_ZONE_ERROR, (TEXT(
			"NODE: DSPNode_Allocate:Failed to CMM handle\r\n")));
	}
	if (!DSP_SUCCEEDED(status)) {
		free(pGPPVirtAddr);
		return status;
	}

	GetNodeType(*phNode, &nodeType);
	if ((nodeType != NODE_DEVICE) && (pInfo.ulNumGPPSMSegs > 0)) {
		/* Messaging uses 1st segment */
		if ((pInfo.segInfo[0].dwSegBasePa != 0) &&
		    (pInfo.segInfo[0].ulTotalSegSize) > 0) {
			pVirtBase = mmap(NULL, pInfo.segInfo[0].ulTotalSegSize,
				 PROT_READ | PROT_WRITE, MAP_SHARED |
				 MAP_LOCKED, hMediaFile,
				 pInfo.segInfo[0].dwSegBasePa);
			if (!pVirtBase) {
				DEBUGMSG(DSPAPI_ZONE_ERROR, (TEXT("NODE: "
				"DSPNode_Allocate:Virt alloc failed\r\n")));
				status = DSP_EMEMORY;
				/* Clean up */
				tempStruct.ARGS_NODE_DELETE.hNode = *phNode;
				DSPTRAP_Trap(&tempStruct,
					CMD_NODE_DELETE_OFFSET);
				return status;
			}
			/* set node translator's virt addr range for seg */
			bufAttr.uAlignment = 0;
			bufAttr.uSegment = 1 | MEMRY_SETVIRTUALSEGID;
			bufAttr.cbStruct = 0;
			status = DSPNode_AllocMsgBuf(*phNode,
					pInfo.segInfo[0].ulTotalSegSize,
					&bufAttr, (BYTE **)&pVirtBase);
			if (DSP_FAILED(status)) {
				/* If failed to set segment, unmap */
				munmap(pVirtBase,
					pInfo.segInfo[0].ulTotalSegSize);
				/* Clean up */
				tempStruct.ARGS_NODE_DELETE.hNode = *phNode;
				DSPTRAP_Trap(&tempStruct,
					CMD_NODE_DELETE_OFFSET);
			}
		}
	}
    return status;
}
コード例 #24
0
ファイル: XnFileDevice.cpp プロジェクト: RikeshThapa/VirtueX
XnStatus XnFileDevice::HandleNewStream(const XnChar *strType, const XnChar *strName, const XnActualPropertiesHash *pInitialValues)
{
    XnStatus nRetVal = XN_STATUS_OK;

    // check if we need to ignore that (stream was not removed upon Rewind).
    XnNodeInfoMap::Iterator it = m_ignoreNewNodes.End();
    if (m_ignoreNewNodes.Find(strName, it) == XN_STATUS_OK)
    {
        // ignore
        return (XN_STATUS_OK);
    }

    XnProductionNodeType type = GetNodeType(strType);
    if (type == -1)
    {
        XN_LOG_WARNING_RETURN(XN_STATUS_CORRUPT_FILE, XN_MASK_FILE, "Invalid node type: %s", strType);
    }

    // find compression type
    XnActualIntProperty* pComp = NULL;
    nRetVal = pInitialValues->Get(XN_STREAM_PROPERTY_COMPRESSION, (XnProperty*&)pComp);
    XN_IS_STATUS_OK(nRetVal);

    XnCodecID codecID = XnCodec::GetCodecIDFromCompressionFormat((XnCompressionFormats)pComp->GetValue());
    if (codecID == XN_CODEC_NULL)
    {
        XN_LOG_WARNING_RETURN(XN_STATUS_CORRUPT_FILE, XN_MASK_FILE, "Invalid compression type: %llu", pComp->GetValue());
    }

    // notify we have a new node
    nRetVal = m_pNotifications->OnNodeAdded(m_pNotificationsCookie, strName, type, codecID);
    XN_IS_STATUS_OK(nRetVal);

    // we support the mirror capability
    nRetVal = m_pNotifications->OnNodeIntPropChanged(m_pNotificationsCookie, strName, XN_CAPABILITY_MIRROR, 1);
    XN_IS_STATUS_OK(nRetVal);

    // we support the extended serialization capability
    nRetVal = m_pNotifications->OnNodeIntPropChanged(m_pNotificationsCookie, strName, XN_CAPABILITY_EXTENDED_SERIALIZATION, 1);
    XN_IS_STATUS_OK(nRetVal);

    // now write state
    for (XnActualPropertiesHash::ConstIterator it = pInitialValues->Begin(); it != pInitialValues->End(); ++it)
    {
        XnProperty* pProp = it->Value();

        switch (pProp->GetType())
        {
        case XN_PROPERTY_TYPE_INTEGER:
        {
            XnActualIntProperty* pIntProp = (XnActualIntProperty*)pProp;
            nRetVal = HandleIntProperty(strName, pProp->GetName(), pIntProp->GetValue());
        }
        break;
        case XN_PROPERTY_TYPE_REAL:
        {
            XnActualRealProperty* pRealProp = (XnActualRealProperty*)pProp;
            nRetVal = HandleRealProperty(strName, pProp->GetName(), pRealProp->GetValue());
        }
        break;
        case XN_PROPERTY_TYPE_STRING:
        {
            XnActualStringProperty* pStrProp = (XnActualStringProperty*)pProp;
            nRetVal = HandleStringProperty(strName, pProp->GetName(), pStrProp->GetValue());
        }
        break;
        case XN_PROPERTY_TYPE_GENERAL:
        {
            XnActualGeneralProperty* pGenProp = (XnActualGeneralProperty*)pProp;
            nRetVal = HandleGeneralProperty(strName, pProp->GetName(), pGenProp->GetValue());
        }
        break;
        default:
            XN_LOG_WARNING_RETURN(XN_STATUS_ERROR, XN_MASK_FILE, "Unknown property type: %d", pProp->GetType());
        }

        XN_IS_STATUS_OK(nRetVal);
    }

    // at this stage, a node should exist with this name
    xn::ProductionNode node;
    nRetVal = m_context.GetProductionNodeByName(strName, node);
    XN_IS_STATUS_OK(nRetVal);

    // S2D & RW
    if (type == XN_NODE_TYPE_DEPTH)
    {
        nRetVal = UpdateS2DTables(xn::DepthGenerator(node));
        XN_IS_STATUS_OK(nRetVal);

        nRetVal = UpdateRWData(xn::DepthGenerator(node));
        XN_IS_STATUS_OK(nRetVal);
    }

    // notify end-of-state
    nRetVal = m_pNotifications->OnNodeStateReady(m_pNotificationsCookie, strName);
    XN_IS_STATUS_OK(nRetVal);

    // add it to the map
    XnNodeInfo nodeInfo = {0};
    nRetVal = m_nodeInfoMap.Set(strName, nodeInfo);
    XN_IS_STATUS_OK(nRetVal);

    // create codec
    nRetVal = CreateCodec(node);
    XN_IS_STATUS_OK(nRetVal);

    // check IR compatibility
    nRetVal = CheckIRCompatibility(node);
    XN_IS_STATUS_OK(nRetVal);

    return (XN_STATUS_OK);
}
コード例 #25
0
FloatVertexAttribute::FloatVertexAttribute() : X3DVertexAttributeNode(GetNodeType()),
	m_numComponents(new SFInt32(NULL, this, 4))
{
}
コード例 #26
0
Sound2D::Sound2D() : X3DSoundNode(GetNodeType())
{
}
コード例 #27
0
Script::Script() : X3DScriptNode(GetNodeType())
{
}
コード例 #28
0
ファイル: Ser.c プロジェクト: jayminer81/NiKom
struct NodeType *selectNodeType(void) {
    struct NodeType *nt;
    int going, i;

    if(Servermem->nodetypes[0].nummer == 0) {
        LogEvent(SYSTEM_LOG, ERROR, "Can't login user, no valid node types found.");
        putstring("\n\n\r*** System error ***\n\n\r", -1, 0);
        return NULL;
    }
    if(Servermem->nodetypes[1].nummer == 0) {
        if((nt = GetNodeType(Servermem->nodetypes[0].nummer)) == NULL) {
            LogEvent(SYSTEM_LOG, ERROR,
                     "Can't login user, the only configured node type (%d) can not be found.",
                     Servermem->nodetypes[0].nummer);
            putstring("\n\n\r*** System error ***\n\n\r", -1, 0);
        }
        return nt;
    }

    if(Servermem->inne[nodnr].shell) {
        nt =  GetNodeType(Servermem->inne[nodnr].shell);
        if(nt == NULL) {
            Servermem->inne[nodnr].shell=0;
        }
    }
    if(Servermem->inne[nodnr].shell == 0) {
        putstring("\n\n\rDu har ingen förinställd nodtyp.\n\n\rVälj mellan:\n\n\r",-1,0);
        for(i = 0; i < MAXNODETYPES; i++) {
            if(Servermem->nodetypes[i].nummer == 0) {
                break;
            }
            sprintf(outbuffer, "%2d: %s\n\r",
                    Servermem->nodetypes[i].nummer, Servermem->nodetypes[i].desc);
            putstring(outbuffer, -1, 0);
        }
        going = TRUE;
        while(going) {
            putstring("\n\rVal: ",-1,0);
            if(getstring(EKO, 2, NULL)) {
                return NULL;
            }
            if(atoi(inmat) < 1) {
                putstring("\n\rDu måste ange ett positivt heltal.\n\r",-1,0);
            }
            else if(!(nt = GetNodeType(atoi(inmat)))) {
                putstring("\n\rFinns ingen sådan nodtyp.\n\r",-1,0);
            }
            else {
                going=FALSE;
            }
        }
        putstring("\n\n\rVill du använda denna nodtyp varje gång du loggar in?",-1,0);
        if(jaellernej('j','n', 1)) {
            putstring("Ja\n\r", -1, 0);
            Servermem->inne[nodnr].shell = nt->nummer;
        } else {
            putstring("Nej\n\r",-1,0);
        }
    }
    return nt;
}
コード例 #29
0
IndexedLineSet2D::IndexedLineSet2D() : X3DGeometryNode(GetNodeType())
{
}
コード例 #30
0
bool XmlCallbackReader::Parse(IContentHandler * pContentHandler)
{
    bool bShouldContinue = true;

    if (pContentHandler)
        mpContentHandler = pContentHandler;

    if (mpContentHandler)
        mpContentHandler->StartDocument();

    while (bShouldContinue && Read() ) {
        if (mpContentHandler) {
            const XmlReader::NodeType nodeType = GetNodeType();

            switch (nodeType) {
                case Element:
                    bShouldContinue = mpContentHandler->StartElement( mpTokenName, mAttributeArray.data(), mAttributeArray.size() / 2 );
                    if (bShouldContinue && IsEmptyElement())
                        bShouldContinue = mpContentHandler->EndElement( mpTokenName );
                    break;

                case EndElement:
                    bShouldContinue = mpContentHandler->EndElement( mpTokenName );
                    break;

                case CharacterData:
                    bShouldContinue = mpContentHandler->Characters( mpTokenValue, (size_t)mValueLength );
                    break;

                case Comment:
                    bShouldContinue = mpContentHandler->Comment( mpTokenValue, (size_t)mValueLength );
                    break;

                case ProcessingInstruction:
                    // As it stands now, the attribute list of the processing instruction is passed as a single unparsed string (mpTokenValue);
                    bShouldContinue = mpContentHandler->ProcessingInstruction( mpTokenName, mpTokenValue );
                    break;

                case EntityRef:
                    bShouldContinue = mpContentHandler->SkippedEntity( mpTokenName );
                    break;

                case None:
                case Document:
                case Prologue:
                case DocTypeDecl:
                case EntityDecl:
                case ElementDecl:
                case AttListDecl:
                case NotationDecl:
                    // To do: We should do something about these types so the user can at least see them.
                    break;
            }
        }
    }

    if (mResultCode == kSuccess) {
        if (mpContentHandler)
            mpContentHandler->EndDocument();
        return true;
    }

    return false;
}