本文整理汇总了C++中Origin类的典型用法代码示例。如果您正苦于以下问题:C++ Origin类的具体用法?C++ Origin怎么用?C++ Origin使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Origin类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SEISCOMP_DEBUG
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
bool StationMagnitude::detachFrom(PublicObject* object) {
if ( object == NULL ) return false;
// check all possible parents
Origin* origin = Origin::Cast(object);
if ( origin != NULL ) {
// If the object has been added already to the parent locally
// just remove it by pointer
if ( object == parent() )
return origin->remove(this);
// The object has not been added locally so it must be looked up
else {
StationMagnitude* child = origin->findStationMagnitude(publicID());
if ( child != NULL )
return origin->remove(child);
else {
SEISCOMP_DEBUG("StationMagnitude::detachFrom(Origin): stationMagnitude has not been found");
return false;
}
}
}
SEISCOMP_ERROR("StationMagnitude::detachFrom(%s) -> wrong class type", object->className());
return false;
}
示例2: total
FPType Utils::checkFeasibility(StarNetwork *net, ODMatrix *mat){
std::vector<FPType> total(net->getNbNodes());
for (int i = 0; i < net->getNbNodes(); ++i) {
total[i] = 0.0;
}
// load demands
for (OriginIterator it = mat->begin(); it != mat->end(); ++it){
Origin* origin = *it;
for (PairODIterator jt = origin->begin(); jt != origin->end(); ++jt) {
PairOD* dest = *jt;
total[origin->getIndex()] += dest->getDemand();
total[dest->getIndex()] -= dest->getDemand();
}
}
//travers network and check
for (StarLink *link = net->beginOnlyLink(); link != NULL; link = net->getNextOnlyLink()) {
total[link->getNodeFromIndex()] -= link->getFlow();
total[link->getNodeToIndex()] += link->getFlow();
}
FPType maxVal = 0.0;
for (int i = 0; i < net->getNbNodes(); ++i) {
if (fabs(total[i]) > maxVal) maxVal = fabs(total[i]);
}
return maxVal;
};
示例3: sub25
void sub25(){
Clone1 a;
Clone2 b;
Origin *p;
p=&a;
if (typeid(*(p->clone(a)))==typeid(Clone1))
cout<<"is"<<endl;
}
示例4: print
void ODMatrix::print(){
std::cout << "nb pairs = " << nbODPairs_ << std::endl;
for (OriginIterator it = begin(); it != end(); ++it){
Origin* origin = *it;
std::cout << "Origin: " << origin->getIndex() << std::endl;
for (PairODIterator jt = origin->begin(); jt != origin->end(); ++jt) {
PairOD* dest = *jt;
dest->print();
}
};
};
示例5: attachTo
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
bool StationMagnitude::attachTo(PublicObject* parent) {
if ( parent == NULL ) return false;
// check all possible parents
Origin* origin = Origin::Cast(parent);
if ( origin != NULL )
return origin->add(this);
SEISCOMP_ERROR("StationMagnitude::attachTo(%s) -> wrong class type", parent->className());
return false;
}
示例6: generateRandomTollsOnShortestPath
void TollsManagement::generateRandomTollsOnShortestPath(TollContainerType& tolls,
FPType probabylity, TollType maxToll, ODMatrix* mat, ShortestPath *shPath){
for (OriginIterator it = mat->begin(); it != mat->end(); ++it) {
Origin* origin = *it;
shPath->calculate(origin->getIndex());
for (PairODIterator jt = origin->begin(); jt != origin->end(); ++jt) {
if (Utils::generateRndNumber(1.0) <= probabylity) {
PairOD* dest = *jt;
assignRndTolls(shPath, dest->getIndex(), tolls, probabylity, maxToll);
}
}
}
};
示例7: attachTo
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
bool Comment::attachTo(PublicObject* parent) {
if ( parent == NULL ) return false;
// check all possible parents
MomentTensor* momentTensor = MomentTensor::Cast(parent);
if ( momentTensor != NULL )
return momentTensor->add(this);
FocalMechanism* focalMechanism = FocalMechanism::Cast(parent);
if ( focalMechanism != NULL )
return focalMechanism->add(this);
Amplitude* amplitude = Amplitude::Cast(parent);
if ( amplitude != NULL )
return amplitude->add(this);
Magnitude* magnitude = Magnitude::Cast(parent);
if ( magnitude != NULL )
return magnitude->add(this);
StationMagnitude* stationMagnitude = StationMagnitude::Cast(parent);
if ( stationMagnitude != NULL )
return stationMagnitude->add(this);
Pick* pick = Pick::Cast(parent);
if ( pick != NULL )
return pick->add(this);
Event* event = Event::Cast(parent);
if ( event != NULL )
return event->add(this);
Origin* origin = Origin::Cast(parent);
if ( origin != NULL )
return origin->add(this);
Parameter* parameter = Parameter::Cast(parent);
if ( parameter != NULL )
return parameter->add(this);
ParameterSet* parameterSet = ParameterSet::Cast(parent);
if ( parameterSet != NULL )
return parameterSet->add(this);
Stream* stream = Stream::Cast(parent);
if ( stream != NULL )
return stream->add(this);
SensorLocation* sensorLocation = SensorLocation::Cast(parent);
if ( sensorLocation != NULL )
return sensorLocation->add(this);
Station* station = Station::Cast(parent);
if ( station != NULL )
return station->add(this);
Network* network = Network::Cast(parent);
if ( network != NULL )
return network->add(this);
SEISCOMP_ERROR("Comment::attachTo(%s) -> wrong class type", parent->className());
return false;
}
示例8: getInLinks
FPType DAGraph::checkOFlowsFeasibility(){
int nbNodes = net_->getNbNodes();
FPType total[nbNodes];
for (int i = 0; i < nbNodes; ++i) {
total[i] = 0.0;
}
// load demands
for (OriginIterator it = mat_->begin(); it != mat_->end(); ++it){
Origin* origin = *it;
if (origin->getIndex() == originIndex_){
for (PairODIterator jt = origin->begin(); jt != origin->end(); ++jt) {
PairOD* dest = *jt;
FPType demand = dest->getDemand();
total[origin->getIndex()] += demand;
total[dest->getIndex()] -= demand;
}
break;
}
}
//travers network and check
int i = -1;
StarLink* link = NULL;
std::list<StarLink*> inLinks;
for (int j = 0; j < nodeSize_; ++j) {
i = nodeIndexes_[j];
getInLinks(i, inLinks);
for (std::list<StarLink*>::iterator it = inLinks.begin(); it != inLinks.end(); ++it){
link = *it;
total[link->getNodeFromIndex()] -= getOriginFlow(link->getIndex());
total[link->getNodeToIndex()] += getOriginFlow(link->getIndex());
}
}
FPType max = 0.0;
for (int i = 0; i < net_->getNbNodes(); ++i) {
if (fabs(total[i]) > max) {
max = fabs(total[i]);
}
}
return max;
};
示例9: setIndexes
void ODMatrix::setIndexes(){
int count = 0;
int originIndex = -1;
//
for (OriginIterator it = begin(); it != end(); ++it){
Origin* origin = *it;
originIndex = origin->getIndex();
for (PairODIterator jt = origin->begin(); jt != origin->end(); ++jt) {
PairOD* dest = *jt;
dest->setODIndex(count);
demandByIndex_.insert(std::make_pair<std::string, FPType>(
createKey(originIndex, dest->getIndex()),
dest->getDemand()));
++count;
}
}
nbODPairs_ = count;
std::cout << "nbODPairs = " << nbODPairs_ << std::endl;
};
示例10: odSetList_
PathSet::PathSet(ODSetType setType, StarNetwork *net, ODMatrix *mat, ShortestPath *shPath,
PathCost *pathCost,
FPType zeroFlow, PathBasedFlowMove* flowMove,
PathBasedFlowMoveWithStep* flowMoveWithStep, PathBasedFlowMoveGP* flowMoveGP,
AONAssignment* aon) :
odSetList_(mat->getNbODPairs()),
size_(mat->getNbODPairs()), currPath_(NULL),
aon_(aon){
int odIndex = -1;
for (OriginIterator it = mat->begin(); it != mat->end(); ++it){
Origin* origin = *it;
for (PairODIterator jt = origin->begin(); jt != origin->end(); ++jt) {
PairOD* dest = *jt;
odIndex = dest->getODIndex();
if (setType == PEAPP3) {
odSetList_[odIndex] = new ODSet(odIndex, dest->getIndex(), origin->getIndex(),
pathCost, net, shPath,
zeroFlow, flowMove);
} else if (setType == WITH_STEP) {
odSetList_[odIndex] = new ODSetWithStep(odIndex, dest->getIndex(), origin->getIndex(),
pathCost, net, shPath, zeroFlow,
flowMoveWithStep);
} else if (setType == GPAPP3) {
odSetList_[odIndex] = new ODSetGPApp3(odIndex, dest->getIndex(), origin->getIndex(),
pathCost, net, shPath, zeroFlow,
flowMoveGP, mat);
} else {
throw Error("Unexpected OD set type.");
}
}
}
};
示例11: SEISCOMP_ERROR
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
bool EventParameters::add(Origin* origin) {
if ( origin == NULL )
return false;
// Element has already a parent
if ( origin->parent() != NULL ) {
SEISCOMP_ERROR("EventParameters::add(Origin*) -> element has already a parent");
return false;
}
if ( PublicObject::IsRegistrationEnabled() ) {
Origin* originCached = Origin::Find(origin->publicID());
if ( originCached ) {
if ( originCached->parent() ) {
if ( originCached->parent() == this )
SEISCOMP_ERROR("EventParameters::add(Origin*) -> element with same publicID has been added already");
else
SEISCOMP_ERROR("EventParameters::add(Origin*) -> element with same publicID has been added already to another object");
return false;
}
else
origin = originCached;
}
}
// Add the element
_origins.push_back(origin);
origin->setParent(this);
// Create the notifiers
if ( Notifier::IsEnabled() ) {
NotifierCreator nc(OP_ADD);
origin->accept(&nc);
}
// Notify registered observers
childAdded(origin);
return true;
}
示例12: updateChild
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
bool EventParameters::updateChild(Object* child) {
Pick* pickChild = Pick::Cast(child);
if ( pickChild != NULL ) {
Pick* pickElement
= Pick::Cast(PublicObject::Find(pickChild->publicID()));
if ( pickElement && pickElement->parent() == this ) {
*pickElement = *pickChild;
return true;
}
return false;
}
Amplitude* amplitudeChild = Amplitude::Cast(child);
if ( amplitudeChild != NULL ) {
Amplitude* amplitudeElement
= Amplitude::Cast(PublicObject::Find(amplitudeChild->publicID()));
if ( amplitudeElement && amplitudeElement->parent() == this ) {
*amplitudeElement = *amplitudeChild;
return true;
}
return false;
}
Reading* readingChild = Reading::Cast(child);
if ( readingChild != NULL ) {
Reading* readingElement
= Reading::Cast(PublicObject::Find(readingChild->publicID()));
if ( readingElement && readingElement->parent() == this ) {
*readingElement = *readingChild;
return true;
}
return false;
}
Origin* originChild = Origin::Cast(child);
if ( originChild != NULL ) {
Origin* originElement
= Origin::Cast(PublicObject::Find(originChild->publicID()));
if ( originElement && originElement->parent() == this ) {
*originElement = *originChild;
return true;
}
return false;
}
FocalMechanism* focalMechanismChild = FocalMechanism::Cast(child);
if ( focalMechanismChild != NULL ) {
FocalMechanism* focalMechanismElement
= FocalMechanism::Cast(PublicObject::Find(focalMechanismChild->publicID()));
if ( focalMechanismElement && focalMechanismElement->parent() == this ) {
*focalMechanismElement = *focalMechanismChild;
return true;
}
return false;
}
Event* eventChild = Event::Cast(child);
if ( eventChild != NULL ) {
Event* eventElement
= Event::Cast(PublicObject::Find(eventChild->publicID()));
if ( eventElement && eventElement->parent() == this ) {
*eventElement = *eventChild;
return true;
}
return false;
}
return false;
}
示例13: process
/**
* @brief Processes and modifies an event. It checks the current
* location against the configured regions and sets the
* type to OUTSIDE_OF_NETWORK_INTEREST if the location is not
* inside in any of the regions.
* @param event The event to be processed
* @return Update flag: true, if the event has been updated, false
* otherwise.
*/
bool process(Event *event) {
Origin *org = Origin::Find(event->preferredOriginID());
if ( !org ) {
SEISCOMP_WARNING("%s: RC: no origin information",
event->publicID().c_str());
return false;
}
try {
if ( org->evaluationMode() == DataModel::MANUAL ){
SEISCOMP_DEBUG("evrc plugin found %s preferred origin %s: "
"do not change the event status",
org->evaluationMode().toString(),
org->publicID().c_str());
return false;
}
}
catch ( ... ) {}
GeoCoordinate location;
try {
location.set(org->latitude().value(), org->longitude().value());
}
catch ( ... ) {
SEISCOMP_WARNING("%s: RC: no lat/lon information available",
event->publicID().c_str());
return false;
}
SEISCOMP_DEBUG("%s: RC: checking regions for location %f / %f",
event->publicID().c_str(), location.lat, location.lon);
OPT(EventType) currentType;
try {
currentType = event->type();
}
catch ( ... ) {}
bool isInside = false;
for ( size_t i = 0; i < _regions.size(); ++i ) {
bool isInsideRegion;
if ( _regions[i].first )
isInsideRegion = _regions[i].first->contains(location);
else
isInsideRegion = true;
if ( _regions[i].second ) {
// Positive region
if ( isInsideRegion ) {
// Inside of network interest
isInside = true;
SEISCOMP_DEBUG("%s: RC: region '%s' matches",
event->publicID().c_str(),
(_regions[i].first ? _regions[i].first->name().c_str() : "world"));
// If there are possible negative regions following this
// match then continue.
if ( !_hasNegativeRegions )
break;
}
}
else {
// Negative region
if ( isInsideRegion ) {
// Outside of network interest
isInside = false;
SEISCOMP_DEBUG("%s: RC: region '%s' matches and it is a negative region",
event->publicID().c_str(),
(_regions[i].first ? _regions[i].first->name().c_str() : "world"));
// Continue with checking as there might follow a positive
// region that overrides again that result unless there
// are only negative regions configured
if ( !_hasPositiveRegions )
break;
}
}
}
if ( !isInside ) {
if ( !currentType || (currentType && *currentType != OUTSIDE_OF_NETWORK_INTEREST) ) {
SEISCOMP_DEBUG("%s: RC: event is out of network interest",
event->publicID().c_str());
event->setType(EventType(OUTSIDE_OF_NETWORK_INTEREST));
return true;
}
//.........这里部分代码省略.........
示例14: SEISCOMP_DEBUG
//.........这里部分代码省略.........
if ( pick != NULL ) {
// If the object has been added already to the parent locally
// just remove it by pointer
if ( object == parent() )
return pick->remove(this);
// The object has not been added locally so it must be looked up
else {
Comment* child = pick->comment(index());
if ( child != NULL )
return pick->remove(child);
else {
SEISCOMP_DEBUG("Comment::detachFrom(Pick): comment has not been found");
return false;
}
}
}
Event* event = Event::Cast(object);
if ( event != NULL ) {
// If the object has been added already to the parent locally
// just remove it by pointer
if ( object == parent() )
return event->remove(this);
// The object has not been added locally so it must be looked up
else {
Comment* child = event->comment(index());
if ( child != NULL )
return event->remove(child);
else {
SEISCOMP_DEBUG("Comment::detachFrom(Event): comment has not been found");
return false;
}
}
}
Origin* origin = Origin::Cast(object);
if ( origin != NULL ) {
// If the object has been added already to the parent locally
// just remove it by pointer
if ( object == parent() )
return origin->remove(this);
// The object has not been added locally so it must be looked up
else {
Comment* child = origin->comment(index());
if ( child != NULL )
return origin->remove(child);
else {
SEISCOMP_DEBUG("Comment::detachFrom(Origin): comment has not been found");
return false;
}
}
}
Parameter* parameter = Parameter::Cast(object);
if ( parameter != NULL ) {
// If the object has been added already to the parent locally
// just remove it by pointer
if ( object == parent() )
return parameter->remove(this);
// The object has not been added locally so it must be looked up
else {
Comment* child = parameter->comment(index());
if ( child != NULL )
return parameter->remove(child);
else {
SEISCOMP_DEBUG("Comment::detachFrom(Parameter): comment has not been found");
return false;
}
}
示例15:
JNIEXPORT void JNICALL Java_org_nzdis_example03_GLESView_myCleanup
(JNIEnv *env, jclass c)
{
SENSORS_ENABLED = 0;
origin.cleanup();
sphere.cleanup();
terrain.cleanup();
}