示例#1
0
vertex_id Network::addVertex() {
	if (isNamed()) throw OperationNotSupportedException("Cannot add an anonymous vertex to a named network");
	max_vertex_id++;
	vertex_id new_vertex_id = max_vertex_id;
	vertexes.insert(new_vertex_id);
	return new_vertex_id;
}
示例#2
0
std::set<long> getKRandom(long max, long k) {
	if (max<k) throw OperationNotSupportedException("Only " + to_string(max) + " values available, requested " + to_string(k));
	std::set<long> res;
	while (res.size()<k)
		res.insert(getRandomInt(max));
	return res;
}
示例#3
0
comparison_result path_length::compare_full(const path_length& other) const {
	bool canBeDominated = true;
	bool canDominate = true;
	if (mnet != other.mnet) {
		throw OperationNotSupportedException("Cannot compare distances on different networks");
	}

	for (LayerSharedPtr layer1: mnet->get_layers()) {
		for (LayerSharedPtr layer2: mnet->get_layers()) {
			long l1 = length(layer1,layer2);
			long l2 = other.length(layer1,layer2);
		    if (l1 > l2) {
		    	canDominate = false;
		    }
		    else if (l1 < l2) {
		    	canBeDominated = false;
		    }
		    if (!canBeDominated && !canDominate)
		    	return INCOMPARABLE;
		}
	}
	if (canDominate && !canBeDominated)
		return GREATER_THAN;
	if (canBeDominated && !canDominate)
		return LESS_THAN;
	//if (canDominate && canBeDominated)
		return EQUAL;
}
示例#4
0
edge_id Network::addEdge(const std::string& vertex_name1, const std::string& vertex_name2) {
	if (!isNamed()) throw OperationNotSupportedException("Cannot reference a named vertex in an unnamed network");
	if (!containsVertex(vertex_name1)) throw ElementNotFoundException("Vertex " + vertex_name1);
	if (!containsVertex(vertex_name2)) throw ElementNotFoundException("Vertex " + vertex_name2);
	//std::cout << "Edge: " << vertex_name1 << " " << vertex_name_to_id[vertex_name1]
	//<< " " << vertex_name2 << " " << vertex_name_to_id[vertex_name2] << std::endl;
	return addEdge(vertex_name_to_id[vertex_name1],vertex_name_to_id[vertex_name2]);
}
示例#5
0
std::set<std::string> Network::getInNeighbors(const std::string& vertex_name) const  {
	if (!isNamed()) throw OperationNotSupportedException("Cannot reference a named vertex in an unnamed network");
	if (!containsVertex(vertex_name)) throw ElementNotFoundException("Vertex " + vertex_name);
	std::set<std::string> neighbors;
	std::set<vertex_id> tmp_id_result = getInNeighbors(vertex_name_to_id.at(vertex_name));
	for (std::set<vertex_id>::iterator it=tmp_id_result.begin(); it!=tmp_id_result.end(); it++)
		neighbors.insert(vertex_id_to_name.at(*it));
	return neighbors;
}
示例#6
0
long getRandomLong(long max) {
	if (max>RAND_MAX) throw OperationNotSupportedException("Requested random value " + to_string(max) + "larger than RAND_MAX constant");
	return rand() % max;
	/*
	// C++11 version:
	std::uniform_int_distribution<long> distribution(0,max-1);
	return distribution(generator);
	*/
}
示例#7
0
vertex_id Network::addVertex(const std::string& vertex_name) {
	if (containsVertex(vertex_name)) throw DuplicateElementException("Vertex " + vertex_name + " already exists");
	if (!isNamed()) throw OperationNotSupportedException("Cannot add a named vertex to an unnamed network");
	max_vertex_id++;
	vertex_id new_vertex_id = max_vertex_id;
	vertexes.insert(new_vertex_id);
	vertex_id_to_name[new_vertex_id] = vertex_name;
	vertex_name_to_id[vertex_name] = new_vertex_id;
	return new_vertex_id;
}
示例#8
0
comparison_result path_length::compare_switch(const path_length& other) const {
	bool canBeDominated = true;
	bool canDominate = true;
	if (mnet != other.mnet) {
		throw OperationNotSupportedException("Cannot compare distances on different networks");
	}
	long num_intralayer_steps1 = 0;
	long num_intralayer_steps2 = 0;
	for (LayerSharedPtr layer1: mnet->get_layers()) {
		long l1 = length(layer1,layer1);
		num_intralayer_steps1 += l1;
		long l2 = other.length(layer1,layer1);
		num_intralayer_steps2 += l2;
		if (l1 > l2) {
			canDominate = false;
		}
		else if (l1 < l2) {
			canBeDominated = false;
		}
		if (!canBeDominated && !canDominate)
			return INCOMPARABLE;
	}
	long num_interlayer_steps1 = length()-num_intralayer_steps1;
	long num_interlayer_steps2 = other.length()-num_intralayer_steps2;
	if (num_interlayer_steps1 > num_interlayer_steps2) {
		canDominate = false;
	}
	else if (num_interlayer_steps1 < num_interlayer_steps2) {
		canBeDominated = false;
	}
	if (!canBeDominated && !canDominate)
		return INCOMPARABLE;
	if (canDominate && !canBeDominated)
		return GREATER_THAN;
	if (canBeDominated && !canDominate)
		return LESS_THAN;
	//if (canDominate && canBeDominated)
		return EQUAL;
}
示例#9
0
comparison_result path_length::compare_simple(const path_length& other) const {
	bool canBeDominated = true;
	bool canDominate = true;
	if (mnet != other.mnet) {
		throw OperationNotSupportedException("Cannot compare distances on different networks");
	}
	long l1 = length();
	long l2 = other.length();
	if (l1 > l2) {
		canDominate = false;
	}
	else if (l1 < l2) {
		canBeDominated = false;
	}
	if (!canBeDominated && !canDominate)
		return INCOMPARABLE;
	if (canDominate && !canBeDominated)
		return GREATER_THAN;
	if (canBeDominated && !canDominate)
		return LESS_THAN;
	//if (canDominate && canBeDominated)
		return EQUAL;
}
示例#10
0
bool Network::deleteVertex(const std::string& vertex_name) {
	if (!isNamed()) throw OperationNotSupportedException("Cannot reference a named vertex in an unnamed network");
	if (!containsVertex(vertex_name)) return false;
	deleteVertex(vertex_name_to_id[vertex_name]);
	return true;
}
示例#11
0
std::string SpeexPlugin::retrievePluginInformation(std::string info,
		std::string subInfo) throw (OperationNotSupportedException,
		OperationNotPerfomedException) {
	MessageType mainInfo = constants[info];
	MessageType secondaryInfo = constants[subInfo];
	std::ostringstream os;
	switch (mainInfo) {
	case __ENCODER_OPT:
		if (!encoder)
			throw OperationNotPerfomedException("encoder not initialized");

		switch (secondaryInfo) {
		case __SPEEX_FRAME_SIZE:
			spx_int32_t framesize;
			speex_encoder_ctl(encoder->state, SPEEX_GET_FRAME_SIZE, &framesize);
			os << framesize;
			return os.str();
			//		case __SPEEX_QUALITY:
			//			spx_int32_t quality;
			//			speex_encoder_ctl(encoderPtr, SPEEX_GET_FRAME_SIZE, &quality);
			//			os << framesize;
			//			return os.str();
		case __SPEEX_MODE:
			spx_int32_t mode;
			speex_encoder_ctl(encoder->state, SPEEX_GET_MODE, &mode);
			os << mode;
			return os.str();
		case __SPEEX_VBR:
			spx_int32_t vbr;
			speex_encoder_ctl(encoder->state, SPEEX_GET_VBR, &vbr);
			os << vbr;
			return os.str();
		case __SPEEX_VBR_QUALITY:
			float vbrquality;
			speex_encoder_ctl(encoder->state, SPEEX_GET_VBR_QUALITY,
					&vbrquality);
			os << vbr;
			return os.str();
		case __SPEEX_COMPLEXITY:
			spx_int32_t complexity;
			speex_encoder_ctl(encoder->state, SPEEX_GET_VBR_QUALITY,
					&complexity);
			os << complexity;
			return os.str();
		case __SPEEX_BITRATE:
			spx_int32_t bitrate;
			speex_encoder_ctl(encoder->state, SPEEX_GET_BITRATE, &bitrate);
			os << bitrate;
			return os.str();
		case __SPEEX_SAMPLING_RATE:
			spx_int32_t samplingrate;
			speex_encoder_ctl(encoder->state, SPEEX_GET_SAMPLING_RATE,
					&samplingrate);
			os << samplingrate;
			return os.str();
		case __SPEEX_VAD:
			spx_int32_t vad;
			speex_encoder_ctl(encoder->state, SPEEX_GET_VAD, &vad);
			os << vad;
			return os.str();
		case __SPEEX_DTX:
			spx_int32_t dtx;
			speex_encoder_ctl(encoder->state, SPEEX_GET_DTX, &dtx);
			os << dtx;
			return os.str();
		case __SPEEX_ABR:
			spx_int32_t abr;
			speex_encoder_ctl(encoder->state, SPEEX_GET_ABR, &abr);
			os << abr;
			return os.str();
		case __SPEEX_PLC_TUNING:
			spx_int32_t tuning;
			speex_encoder_ctl(encoder->state, SPEEX_GET_PLC_TUNING, &tuning);
			os << tuning;
			return os.str();
		case __SPEEX_VBR_MAX_BITRATE:
			spx_int32_t maxbitrate;
			speex_encoder_ctl(encoder->state, SPEEX_GET_VBR_MAX_BITRATE,
					&maxbitrate);
			os << maxbitrate;
			return os.str();
		case __SPEEX_HIGHPASS:
			spx_int32_t highpass;
			speex_encoder_ctl(encoder->state, SPEEX_GET_HIGHPASS, &highpass);
			os << highpass;
			return os.str();
		default:
			throw OperationNotSupportedException("param not supported");
		}
		break;
	case __DECODER_OPT:
		if (!decoder)
			throw OperationNotPerfomedException("decoder not initialized");

		switch (secondaryInfo) {
		case __SPEEX_ENH:
			spx_int32_t enh;
			speex_decoder_ctl(decoder->state, SPEEX_GET_ENH, &enh);
			os << enh;
			return os.str();
		case __SPEEX_FRAME_SIZE:
			spx_int32_t framesize;
			speex_decoder_ctl(decoder->state, SPEEX_GET_FRAME_SIZE, &framesize);
			os << framesize;
			return os.str();
		case __SPEEX_BITRATE:
			spx_int32_t bitrate;
			speex_decoder_ctl(decoder->state, SPEEX_GET_BITRATE, &bitrate);
			os << bitrate;
			return os.str();
		case __SPEEX_SAMPLING_RATE:
			spx_int32_t samplingrate;
			speex_decoder_ctl(decoder->state, SPEEX_GET_SAMPLING_RATE,
					&samplingrate);
			os << samplingrate;
			return os.str();
		case __SPEEX_HIGHPASS:
			spx_int32_t highpass;
			speex_decoder_ctl(decoder->state, SPEEX_GET_HIGHPASS, &highpass);
			os << highpass;
			return os.str();
		default:
			throw OperationNotSupportedException("param not supported");
		}
		break;
	case __PREPROCESS_OPT:
		if (!preprocess)
			throw OperationNotPerfomedException("Preprocess not initialized");
		switch (secondaryInfo) {
		case __SPEEX_PREPROCESS_DENOISE:
			spx_int32_t denoise;
			speex_preprocess_ctl(preprocess, SPEEX_PREPROCESS_GET_DENOISE,
					&denoise);
			os << denoise;
			return os.str();
		case __SPEEX_PREPROCESS_AGC:
			spx_int32_t agc;
			speex_preprocess_ctl(preprocess, SPEEX_PREPROCESS_GET_AGC, &agc);
			os << agc;
			return os.str();
		case __SPEEX_PREPROCESS_AGC_LEVEL:
			float agclevel;
			speex_preprocess_ctl(preprocess, SPEEX_PREPROCESS_GET_AGC_LEVEL,
					&agclevel);
			os << agclevel;
			return os.str();
		case __SPEEX_PREPROCESS_DEREVERB:
			spx_int32_t dereverb;
			speex_preprocess_ctl(preprocess, SPEEX_PREPROCESS_GET_DEREVERB,
					&dereverb);
			os << dereverb;
			return os.str();
		case __SPEEX_PREPROCESS_DEREVERB_LEVEL:
			spx_int32_t dereverblevel;
			speex_preprocess_ctl(preprocess,
					SPEEX_PREPROCESS_GET_DEREVERB_LEVEL, &dereverblevel);
			os << dereverblevel;
			return os.str();
		case __SPEEX_PREPROCESS_DEREVERB_DECAY:
			spx_int32_t dereverbdecay;
			speex_preprocess_ctl(preprocess,
					SPEEX_PREPROCESS_GET_DEREVERB_DECAY, &dereverbdecay);
			os << dereverbdecay;
			return os.str();
		case __SPEEX_PREPROCESS_PROB_START:
			spx_int32_t probstart;
			speex_preprocess_ctl(preprocess, SPEEX_PREPROCESS_GET_PROB_START,
					&probstart);
			os << probstart;
			return os.str();
		case __SPEEX_PREPROCESS_PROB_CONTINUE:
			spx_int32_t probcontinue;
			speex_preprocess_ctl(preprocess,
					SPEEX_PREPROCESS_GET_PROB_CONTINUE, &probcontinue);
			os << probcontinue;
			return os.str();
		case __SPEEX_PREPROCESS_NOISE_SUPRESS:
			spx_int32_t noisesupress;
			speex_preprocess_ctl(preprocess,
					SPEEX_PREPROCESS_GET_NOISE_SUPPRESS, &noisesupress);
			os << noisesupress;
			return os.str();
		case __SPEEX_PREPROCESS_ECHO_SUPRESS:
			spx_int32_t echosupress;
			speex_preprocess_ctl(preprocess,
					SPEEX_PREPROCESS_GET_ECHO_SUPPRESS, &echosupress);
			os << echosupress;
			return os.str();
		case __SPEEX_PREPROCESS_ECHO_SUPRESS_ACTIVE:
			spx_int32_t echosupressactive;
			speex_preprocess_ctl(preprocess,
					SPEEX_PREPROCESS_GET_ECHO_SUPPRESS_ACTIVE,
					&echosupressactive);
			os << echosupressactive;
			return os.str();
			//		case __SPEEX_PREPROCESS_ECHO_STATE:  For now, it just disabled. Use enable/disable echo cancellation instead
			//			spx_int32_t echostate;
			//			speex_preprocess_ctl(preprocess, SPEEX_PREPROCESS_GET_ECHO_STATE,
			//					&echostate);
			//			os << echostate;
			//			return os.str();
		default:
			throw OperationNotSupportedException("Invalid Option in preprocess");

		}

	default:
		throw OperationNotSupportedException("param not supported");
	};

}
示例#12
0
void SpeexPlugin::adaptStream(std::string paramName, std::map<std::string,
		std::string> &params) throw (OperationNotPerfomedException,
		OperationNotSupportedException) {
	MessageType mainInfo = constants[paramName];
	switch (mainInfo) {
	case __ENCODER_OPT:
		if (!encoder)
			throw OperationNotPerfomedException("encoder not initialized");
		for (std::map<std::string, std::string>::iterator it = params.begin(); it
				!= params.end(); it++) {
			MessageType second = constants[it->first];
			std::istringstream is(it->first);
			switch (second) {
			case __SPEEX_QUALITY:
				spx_int32_t quality;
				is >> quality;
				if (is.fail())
					throw OperationNotPerfomedException(
							"Invalid parameter: quality");
				if (speex_encoder_ctl(encoder->state, SPEEX_SET_QUALITY,
						&quality))
					throw OperationNotPerfomedException(
							"Problem in set quality property");
				break;
			case __SPEEX_MODE:
				spx_int32_t mode;
				is >> mode;
				if (is.fail())
					throw OperationNotPerfomedException(
							"Invalid parameter: mode");
				if (speex_encoder_ctl(encoder->state, SPEEX_SET_MODE, &mode))
					throw OperationNotPerfomedException(
							"Problem in set mode property");
				break;
			case __SPEEX_VBR:
				spx_int32_t vbr;
				is >> vbr;
				if (is.fail())
					throw OperationNotPerfomedException(
							"Invalid parameter: vbr");
				if (speex_encoder_ctl(encoder->state, SPEEX_SET_VBR, &vbr))
					throw OperationNotPerfomedException(
							"Problem in set vbr property");
				break;
			case __SPEEX_VBR_QUALITY:
				float vbrquality;
				is >> vbrquality;
				if (is.fail())
					throw OperationNotPerfomedException(
							"Invalid parameter: vbrquality");
				if (speex_encoder_ctl(encoder->state, SPEEX_SET_VBR,
						&vbrquality))
					throw OperationNotPerfomedException(
							"Problem in set vbrquality property");
				break;
			case __SPEEX_COMPLEXITY:
				spx_int32_t complexity;
				is >> complexity;
				if (is.fail())
					throw OperationNotPerfomedException(
							"Invalid parameter: complexity");
				if (speex_encoder_ctl(encoder->state, SPEEX_SET_COMPLEXITY,
						&complexity))
					throw OperationNotPerfomedException(
							"Invalid parameter: complexity");
				break;
			case __SPEEX_BITRATE:
				spx_int32_t bitrate;
				is >> bitrate;
				if (is.fail())
					throw OperationNotPerfomedException(
							"Invalid parameter: complexity");
				if (speex_encoder_ctl(encoder->state, SPEEX_SET_BITRATE,
						&bitrate))
					throw OperationNotPerfomedException(
							"Invalid parameter: bitrate");
				break;
			case __SPEEX_SAMPLING_RATE:
				spx_int32_t samplingrate;
				is >> samplingrate;
				if (is.fail())
					throw OperationNotPerfomedException(
							"Invalid parameter: samplingrate");
				if (speex_encoder_ctl(encoder->state, SPEEX_SET_SAMPLING_RATE,
						&samplingrate))
					throw OperationNotPerfomedException(
							"Invalid parameter: bitsamplingraterate");
				break;
			case __SPEEX_RESET_STATE:
				speex_encoder_ctl(encoder->state, SPEEX_RESET_STATE, 0);
				break;
			case __SPEEX_VAD:
				spx_int32_t vad;
				is >> vad;
				if (is.fail())
					throw OperationNotPerfomedException(
							"Invalid parameter: vad");
				if (speex_encoder_ctl(encoder->state, SPEEX_SET_VAD, &vad))
					throw OperationNotPerfomedException(
							"Invalid parameter: vad");
				break;
			case __SPEEX_DTX:
				spx_int32_t dtx;
				is >> dtx;
				if (is.fail())
					throw OperationNotPerfomedException(
							"Invalid parameter: dtx");
				if (speex_encoder_ctl(encoder->state, SPEEX_SET_DTX, &dtx))
					throw OperationNotPerfomedException(
							"Invalid parameter: dtx");
				break;
			case __SPEEX_ABR:
				spx_int32_t abr;
				is >> abr;
				if (is.fail())
					throw OperationNotPerfomedException(
							"Invalid parameter: abr");
				if (speex_encoder_ctl(encoder->state, SPEEX_SET_ABR, &abr))
					throw OperationNotPerfomedException(
							"Invalid parameter: abr");
				break;
			case __SPEEX_PLC_TUNING:
				spx_int32_t plc;
				is >> plc;
				if (is.fail())
					throw OperationNotPerfomedException(
							"Invalid parameter: plc");
				if (speex_encoder_ctl(encoder->state, SPEEX_SET_PLC_TUNING,
						&plc))
					throw OperationNotPerfomedException(
							"Invalid parameter: plc");
				break;
			case __SPEEX_VBR_MAX_BITRATE:
				spx_int32_t vbrmaxbitrate;
				is >> vbrmaxbitrate;
				if (is.fail())
					throw OperationNotPerfomedException(
							"Invalid parameter: vbrmaxbitrate");
				if (speex_encoder_ctl(encoder->state,
						SPEEX_SET_VBR_MAX_BITRATE, &vbrmaxbitrate))
					throw OperationNotPerfomedException(
							"Invalid parameter: vbrmaxbitrate");
				break;
			case __SPEEX_HIGHPASS:
				spx_int32_t highpass;
				is >> highpass;
				if (is.fail())
					throw OperationNotPerfomedException(
							"Invalid parameter: highpass");
				if (speex_encoder_ctl(encoder->state, SPEEX_SET_HIGHPASS,
						&highpass))
					throw OperationNotPerfomedException(
							"Invalid parameter: highpass");
				break;
			default:
				throw OperationNotSupportedException();
			}
		}
		break;
	case __DECODER_OPT:
		if (!decoder)
			throw OperationNotPerfomedException("decoder not initialized");
		for (std::map<std::string, std::string>::iterator it = params.begin(); it
				!= params.end(); it++) {
			MessageType second = constants[it->first];
			std::istringstream is(it->first);

			switch (second) {
			case __SPEEX_ENH:
				spx_int32_t enh;
				is >> enh;
				if (is.fail())
					throw OperationNotPerfomedException(
							"Invalid parameter: enh");
				if (speex_decoder_ctl(decoder->state, SPEEX_SET_ENH, &enh))
					throw OperationNotPerfomedException(
							"Invalid parameter: enh");
				break;
			case __SPEEX_SAMPLING_RATE:
				spx_int32_t samplingrate;
				is >> samplingrate;
				if (is.fail())
					throw OperationNotPerfomedException(
							"Invalid parameter: samplingrate");
				if (speex_decoder_ctl(decoder->state, SPEEX_SET_SAMPLING_RATE,
						&samplingrate))
					throw OperationNotPerfomedException(
							"Invalid parameter: bitsamplingraterate");
				break;
			case __SPEEX_RESET_STATE:
				speex_decoder_ctl(decoder->state, SPEEX_RESET_STATE, 0);
				break;
			case __SPEEX_HIGHPASS:
				spx_int32_t highpass;
				is >> highpass;
				if (is.fail())
					throw OperationNotPerfomedException(
							"Invalid parameter: highpass");
				if (speex_decoder_ctl(decoder->state, SPEEX_SET_HIGHPASS,
						&highpass))
					throw OperationNotPerfomedException(
							"Invalid parameter: highpass");
				break;
			default:
				throw OperationNotSupportedException();

			}

		}
		break;
	case __PREPROCESS_OPT:
		if (!preprocess)
			throw OperationNotPerfomedException("Preprocess not initialized");

		for (std::map<std::string, std::string>::iterator it = params.begin(); it
				!= params.end(); it++) {
			MessageType second = constants[it->first];
			std::istringstream is(it->first);

			switch (second) {

			case __SPEEX_PREPROCESS_DENOISE:
				spx_int32_t denoise;
				is >> denoise;
				if (is.fail() || speex_preprocess_ctl(preprocess,
						SPEEX_PREPROCESS_SET_DENOISE, &denoise))
					throw OperationNotPerfomedException(
							"Invalid parameter: denoise");
				break;

			case __SPEEX_PREPROCESS_AGC:
				spx_int32_t agc;
				is >> agc;
				if (is.fail() || speex_preprocess_ctl(preprocess,
						SPEEX_PREPROCESS_SET_AGC, &agc))
					throw OperationNotPerfomedException(
							"Invalid parameter: agc");
				break;

			case __SPEEX_PREPROCESS_AGC_LEVEL:
				float agclevel;
				is >> agclevel;
				if (is.fail() || speex_preprocess_ctl(preprocess,
						SPEEX_PREPROCESS_SET_AGC_LEVEL, &agclevel))
					throw OperationNotPerfomedException(
							"Invalid parameter: agclevel");
				break;

			case __SPEEX_PREPROCESS_DEREVERB:
				spx_int32_t dereverb;
				is >> dereverb;
				if (is.fail() || speex_preprocess_ctl(preprocess,
						SPEEX_PREPROCESS_SET_DEREVERB, &dereverb))
					throw OperationNotPerfomedException(
							"Invalid parameter: dereverb");
				break;

			case __SPEEX_PREPROCESS_DEREVERB_LEVEL:
				spx_int32_t dereverblevel;
				is >> dereverblevel;
				if (is.fail() || speex_preprocess_ctl(preprocess,
						SPEEX_PREPROCESS_SET_DEREVERB_LEVEL, &dereverblevel))
					throw OperationNotPerfomedException(
							"Invalid parameter: dereverblevel");
				break;

			case __SPEEX_PREPROCESS_DEREVERB_DECAY:
				spx_int32_t dereverbdecay;
				is >> dereverbdecay;
				if (is.fail() || speex_preprocess_ctl(preprocess,
						SPEEX_PREPROCESS_SET_DEREVERB_DECAY, &dereverbdecay))
					throw OperationNotPerfomedException(
							"Invalid parameter: dereverbdecay");
				break;

			case __SPEEX_PREPROCESS_PROB_START:
				spx_int32_t probstart;
				is >> probstart;
				if (is.fail() || speex_preprocess_ctl(preprocess,
						SPEEX_PREPROCESS_SET_PROB_START, &probstart))
					throw OperationNotPerfomedException(
							"Invalid parameter: probstart");
				break;

			case __SPEEX_PREPROCESS_PROB_CONTINUE:
				spx_int32_t probcontinue;
				is >> probcontinue;
				if (is.fail() || speex_preprocess_ctl(preprocess,
						SPEEX_PREPROCESS_SET_PROB_CONTINUE, &probcontinue))
					throw OperationNotPerfomedException(
							"Invalid parameter: probcontinue");
				break;

			case __SPEEX_PREPROCESS_NOISE_SUPRESS:
				spx_int32_t noisesupress;
				is >> noisesupress;
				if (is.fail() || speex_preprocess_ctl(preprocess,
						SPEEX_PREPROCESS_SET_NOISE_SUPPRESS, &noisesupress))
					throw OperationNotPerfomedException(
							"Invalid parameter: noisesupress");
				break;

			case __SPEEX_PREPROCESS_ECHO_SUPRESS:

				spx_int32_t echosupress;
				is >> echosupress;
				if (is.fail() || speex_preprocess_ctl(preprocess,
						SPEEX_PREPROCESS_SET_ECHO_SUPPRESS, &echosupress))
					throw OperationNotPerfomedException(
							"Invalid parameter: echosupress");
				break;

			case __SPEEX_PREPROCESS_ECHO_SUPRESS_ACTIVE:

				spx_int32_t echosupressactive;
				is >> echosupressactive;
				if (is.fail() || speex_preprocess_ctl(preprocess,
						SPEEX_PREPROCESS_SET_ECHO_SUPPRESS_ACTIVE,
						&echosupressactive))
					throw OperationNotPerfomedException(
							"Invalid parameter: echosupressactive");
				break;

			default:
				throw OperationNotSupportedException(
						"Invalid option to Preprocessing");
			};
		}
	default:
		throw OperationNotSupportedException();
	};
}
示例#13
0
edge_id Network::addEdge(const std::string& vertex_name1, const std::string& vertex_name2, double weight) {
	if (!isNamed()) throw OperationNotSupportedException("Cannot reference a named vertex in an unnamed network");
	if (!containsVertex(vertex_name1)) throw ElementNotFoundException("Vertex " + vertex_name1);
	if (!containsVertex(vertex_name2)) throw ElementNotFoundException("Vertex " + vertex_name2);
	return addEdge(vertex_name_to_id[vertex_name1],vertex_name_to_id[vertex_name2], weight);
}
示例#14
0
bool Network::containsEdge(const std::string& vertex_name1, const std::string& vertex_name2) const {
	if (!isNamed()) throw OperationNotSupportedException("Cannot reference a named edge in an unnamed network");
	if (!containsVertex(vertex_name1)) return false;
	if (!containsVertex(vertex_name2)) return false;
	return containsEdge(vertex_name_to_id.at(vertex_name1),vertex_name_to_id.at(vertex_name2));
}
示例#15
0
double Network::getEdgeWeight(vertex_id vid1, vertex_id vid2) const {
	if (!isWeighted()) throw OperationNotSupportedException("Network is unweighed");
	return getNumericEdgeAttribute(vid1, vid2, "weight");
}
示例#16
0
void Network::setStringEdgeAttribute(const std::string& vertex_name1, const std::string& vertex_name2, const std::string& attribute_name, const std::string& val) {
	if (!isNamed()) throw OperationNotSupportedException("Cannot reference a named vertex in an unnamed network");
	if (!containsVertex(vertex_name1)) throw ElementNotFoundException("Vertex " + vertex_name1);
	if (!containsVertex(vertex_name2)) throw ElementNotFoundException("Vertex " + vertex_name2);
	setStringEdgeAttribute(vertex_name_to_id.at(vertex_name1), vertex_name_to_id.at(vertex_name2), attribute_name, val);
}
示例#17
0
void Network::setStringVertexAttribute(const std::string& vertex_name, const std::string& attribute_name, const std::string& val) {
	if (!isNamed()) throw OperationNotSupportedException("Cannot reference a named vertex in an unnamed network");
	setStringVertexAttribute(vertex_name_to_id[vertex_name], attribute_name, val);
}
示例#18
0
double Network::getNumericEdgeAttribute(const std::string& vertex_name1, const std::string& vertex_name2, const std::string& attribute_name) const {
	if (!isNamed()) throw OperationNotSupportedException("Cannot reference a named vertex in an unnamed network");
	if (!containsVertex(vertex_name1)) throw ElementNotFoundException("Vertex " + vertex_name1);
	if (!containsVertex(vertex_name2)) throw ElementNotFoundException("Vertex " + vertex_name2);
	return getNumericEdgeAttribute(vertex_name_to_id.at(vertex_name1), vertex_name_to_id.at(vertex_name2), attribute_name);
}
示例#19
0
std::string Network::getVertexName(vertex_id vid) const  {
	if (!isNamed()) throw OperationNotSupportedException("Cannot reference a named vertex in an unnamed network");
	if (!containsVertex(vid)) throw ElementNotFoundException("Vertex " + std::to_string(vid));
	return vertex_id_to_name.at(vid);
}
示例#20
0
void Network::setEdgeWeight(const std::string& vertex_name1, const std::string& vertex_name2, double weight) {
	if (!isWeighted()) throw OperationNotSupportedException("Network is unweighed");
	setNumericEdgeAttribute(vertex_name1, vertex_name2, "weight", weight);
}
示例#21
0
double Network::getEdgeWeight(const std::string& vertex_name1, const std::string& vertex_name2) const {
	if (!isWeighted()) throw OperationNotSupportedException("Network is unweighed");
	return getNumericEdgeAttribute(vertex_name1, vertex_name2, "weight");
}
示例#22
0
void Network::setEdgeWeight(vertex_id vid1, vertex_id vid2, double weight) {
	if (!isWeighted()) throw OperationNotSupportedException("Network is unweighed");
	setNumericEdgeAttribute(vid1, vid2, "weight", weight);
}
示例#23
0
edge_id Network::addEdge(vertex_id vid1, vertex_id vid2, double weight) {
	if (!isWeighted()) throw OperationNotSupportedException("Cannot add a weight: network is unweighed");
	addEdge(vid1,vid2);
	setNumericEdgeAttribute(vid1, vid2, "weight", weight);
	return edge_id(vid1, vid2, isDirected());
}
void FileTransferReplyBuffer::onMd5DataReply()
{
  throw OperationNotSupportedException();
}
示例#25
0
vertex_id Network::getVertexId(const std::string& vertex_name) const  {
	if (!isNamed()) throw OperationNotSupportedException("Cannot reference a named vertex in an unnamed network");
	if (!containsVertex(vertex_name)) throw ElementNotFoundException("Vertex " + vertex_name);
	return vertex_name_to_id.at(vertex_name);
}