예제 #1
0
파일: atom_links.cpp 프로젝트: apolitis/imp
void HierarchyLoadLink::create_recursive(kernel::Model *m,
                                         kernel::ParticleIndex root,
                                         kernel::ParticleIndex cur,
                                         RMF::NodeConstHandle name,
                                         kernel::ParticleIndexes rigid_bodies,
                                         Data &data) {
  set_association(name, m->get_particle(cur));
  unsigned int state = get_coords_state(name, intermediate_particle_factory_,
                                        reference_frame_factory_);
  data.load_static.setup_particle(name, m, cur, rigid_bodies);
  data.load_local_coordinates.setup_particle(name, state, m, cur, rigid_bodies);
  data.load_static_coordinates.setup_particle(name, state, m, cur,
                                              rigid_bodies);
  data.load_global_coordinates.setup_particle(name, state, m, cur,
                                              rigid_bodies);

  if (core::RigidBody::get_is_setup(m, cur)) {
    rigid_bodies.push_back(cur);
  }
  RMF::NodeConstHandles ch = name.get_children();
  for (unsigned int i = 0; i < ch.size(); ++i) {
    if (ch[i].get_type() == RMF::REPRESENTATION) {
      kernel::ParticleIndex child = m->add_particle(ch[i].get_name());
      atom::Hierarchy(m, cur)
          .add_child(atom::Hierarchy::setup_particle(m, child));
      create_recursive(m, root, child, ch[i], rigid_bodies, data);
    }
  }
  do_setup_particle(m, root, cur, name);
}
예제 #2
0
파일: atom_links.cpp 프로젝트: apolitis/imp
void HierarchySaveLink::add_recursive(Model *m, kernel::ParticleIndex root,
                                      kernel::ParticleIndex p,
                                      kernel::ParticleIndexes rigid_bodies,
                                      RMF::NodeHandle cur, Data &data) {
  IMP_LOG_VERBOSE("Adding " << atom::Hierarchy(m, p) << std::endl);
  // make sure not to double add
  if (p != root) set_association(cur, m->get_particle(p));
  data.save_static.setup_node(m, p, cur);
  bool local_coords =
      data.save_local_coordinates.setup_node(m, p, cur, rigid_bodies);
  bool global_coords =
      data.save_global_coordinates.setup_node(m, p, cur, rigid_bodies);
  bool static_coords =
      data.save_static_coordinates.setup_node(m, p, cur, rigid_bodies);
  IMP_INTERNAL_CHECK(!local_coords || !global_coords,
                     "A particle can't have saved local and global coords");

  do_setup_node(m, root, p, cur);

  if (core::RigidBody::get_is_setup(m, p)) {
    rigid_bodies.push_back(p);
  }
  for (unsigned int i = 0; i < atom::Hierarchy(m, p).get_number_of_children();
       ++i) {
    kernel::ParticleIndex pc = atom::Hierarchy(m, p).get_child_index(i);
    RMF::NodeHandle curc =
        cur.add_child(get_good_name(m, pc), RMF::REPRESENTATION);
    add_recursive(m, root, pc, rigid_bodies, curc, data);
  }
}
예제 #3
0
파일: atom_links.cpp 프로젝트: apolitis/imp
void HierarchyLoadLink::add_link_recursive(kernel::Model *m,
                                           kernel::ParticleIndex root,
                                           kernel::ParticleIndex cur,
                                           RMF::NodeConstHandle node,
                                           kernel::ParticleIndexes rigid_bodies,
                                           Data &data) {
  IMP_USAGE_CHECK(get_good_name(m, cur) == node.get_name(),
                  "Names don't match");
  set_association(node, m->get_particle(cur), true);
  RMF::NodeConstHandles ch = node.get_children();
  unsigned int state = get_coords_state(node, intermediate_particle_factory_,
                                        reference_frame_factory_);
  data.load_static.link_particle(node, m, cur, rigid_bodies);
  data.load_global_coordinates.link_particle(node, state, m, cur, rigid_bodies);
  // data.load_static_coordinates.link_particle(node, m, cur, rigid_bodies);
  data.load_local_coordinates.link_particle(node, state, m, cur, rigid_bodies);

  do_link_particle(m, root, cur, node);

  if (core::RigidBody::get_is_setup(m, cur)) {
    rigid_bodies.push_back(cur);
  }
  int child = 0;
  for (unsigned int i = 0; i < ch.size(); ++i) {
    if (ch[i].get_type() == RMF::REPRESENTATION) {
      add_link_recursive(m, root,
                         atom::Hierarchy(m, cur).get_child_index(child), ch[i],
                         rigid_bodies, data);
      ++child;
    }
  }
}
예제 #4
0
RelationData::RelationData(const BrowserRelation * model,
                           BrowserRelation * r)
    : ClassMemberData((ClassMemberData *) model->get_data()),
      Labeled<RelationData>(all, 0), is_deleted(FALSE), is_unconsistent(FALSE)
{
    RelationData * md = (RelationData *) model->get_data();

    type = md->type;
    name = md->name;
    a = md->a;
    b = md->b;
    set_association(md->association);
    original_id = 0;

    if (md->start == model) {
        start = r;

        if (md->end_removed_from == 0) {
            // bi dir, self to model became self to r
            end = new BrowserRelation((md->get_end_class() == (BrowserClass *) model->parent())
                                      ? (BrowserClass *) r->parent() : md->get_end_class(),
                                      this);
            end_removed_from = 0;
        }
        else {
            // uni dir
            end = 0;
            end_removed_from = (md->end_removed_from == (BrowserClass *) model->parent())
                               ? (BrowserClass *) r->parent() : md->end_removed_from;
            connect(end_removed_from->get_data(), SIGNAL(deleted()),
                    this, SLOT(end_deleted()));
        }
    }
    else {
        // bi dir, self to model became self to r
        end = r;
        start = new BrowserRelation((md->get_start_class() == (BrowserClass *) model->parent())
                                    ? (BrowserClass *) r->parent() : md->get_start_class(),
                                    this);
        end_removed_from = 0;
    }

    if (get_start_class() == md->get_start_class())
        // to not have two times the same role name
        a.role = 0;

    if ((end != 0) && (get_end_class() == md->get_end_class()))
        // to not have two times the same role name
        b.role = 0;
}
예제 #5
0
bool RelationData::tool_cmd(ToolCom * com, BrowserRelation * rel,
                            const char * args)
{
    if (((unsigned char) args[-1]) >= firstSetCmd) {
        if (!rel->is_writable() && !root_permission())
            com->write_ack(FALSE);
        else {
            RoleData & r = (rel == start) ? a : b;

            switch ((unsigned char) args[-1]) {
            case setDescriptionCmd:
                r.comment = args;
                break;

            case setStereotypeCmd:
                set_stereotype(args);
                modified();
                com->write_ack(TRUE);

                // send the other side to update it
                if (rel == start) {
                    if (end != 0)
                        end->write_id(com);
                    else
                        com->write_id(0);
                }
                else
                    start->write_id(com);

                return TRUE;

            case setRelationAssocClassCmd: {
                AType t;

                com->get_type(t, args);
                set_association(t);
                modified();
                com->write_ack(TRUE);

                // send the other side to update it
                if (rel == start) {
                    if (end != 0)
                        end->write_id(com);
                    else
                        com->write_id(0);
                }
                else
                    start->write_id(com);
            }

            return TRUE;

            case setNameCmd:
                name = args;
                break;

            case setDefaultValueCmd:
                r.init_value = args;
                break;

            case setIsClassMemberCmd:
                r.isa_class_relation = (*args != 0);
                break;

            case setIsVolatileCmd:
                r.isa_volatile_relation = (*args != 0);
                break;

            case setVisibilityCmd: {
                UmlVisibility v;

                if (! com->get_visibility(v, args)) {
                    com->write_ack(FALSE);
                    return TRUE;
                }

                r.uml_visibility = v;
            }
            break;

            case setConstraintCmd:
                r.constraint = args;
                break;

            case setCppDeclCmd:
                r.cpp_decl = args;
                break;

            case setJavaDeclCmd:
                r.java_decl = args;
                break;

            case setJavaAnnotationCmd: {
                WrapperStr s = args;

                s = s.stripWhiteSpace();

                if (! s.isEmpty())
                    s += '\n';

                r.java_annotation = s;
            }
            break;

            case setPhpDeclCmd:
                r.php_decl = args;
                break;

            case setPythonDeclCmd:
                r.python_decl = args;
                break;

            case setIdlDeclCmd:
                r.idl_decl = args;
                break;

            case setCppVisibilityCmd: {
                UmlVisibility v;

                if (! com->get_visibility(v, args)) {
                    com->write_ack(FALSE);
                    return TRUE;
                }

                r.cpp_visibility = v;
            }
            break;

            case setIsReadOnlyCmd:
                r.isa_const_relation = (*args != 0);
                break;

            case setIsCppMutableCmd:
                r.cpp_mutable = (*args != 0);
                break;

            case setRoleNameCmd:
                if ((rel == start) ? wrong_role_a_name(args)
                    : wrong_role_b_name(args)) {
                    com->write_ack(FALSE);
                    return TRUE;
                }

                r.role = args;
                break;

            case setMultiplicityCmd:
                r.multiplicity = args;
                break;

            case setCppVirtualInheritanceCmd:
                r.cpp_virtual_inheritance = (*args != 0);
                break;

            case setIsIdlTruncatableCmd:
                r.idl_truncatable_inheritance = (*args != 0);;
                break;

            case setIsJavaTransientCmd:
                r.java_transient = (*args != 0);
                break;

            case setIdlCaseCmd: {
                BrowserAttribute * at = (BrowserAttribute *) com->get_id(args);

                set_idlcase(r, at, args);
            }
            break;

            case setDerivedCmd:
                switch (*args) {
                case 0:
                    r.is_derived = r.is_derivedunion = FALSE;
                    break;

                case 1:
                    r.is_derived = TRUE;
                    r.is_derivedunion = FALSE;
                    break;

                case 3:
                    r.is_derived = r.is_derivedunion = TRUE;
                    break;

                default:
                    // derived union but non derived
                    com->write_ack(FALSE);
                    return TRUE;
                }

                break;

            case setOrderingCmd:
                r.is_ordered = (*args != 0);
                break;

            case setUniqueCmd:
                r.is_unique = (*args != 0);
                break;

            case setTypeCmd:
                // only inside associations
            {
                UmlCode c;

                if (!com->get_relation_kind(c, args)) {
                    com->write_ack(FALSE);
                    return TRUE;
                }
                else {
                    type = c;

                    if (end)
                        end->package_modified();

                    if (check_end_visibility())
                        end->modified();

                    start->modified();
                    start->package_modified();
                    modified();
                }
            }
            break;

            default:
                return FALSE;
            }

            // ok case
            if (rel == start) {
                start->modified();
                start->package_modified();
            }
            else {
                end->modified();
                end->package_modified();
            }

            modified();
            com->write_ack(TRUE);
        }
    }
    else {
        switch ((unsigned char) args[-1]) {
        case getDefCmd:
            send_uml_def(com, rel);
            send_cpp_def(com, rel);
            send_java_def(com, rel);

            if (com->api_format() >= 34) {
                send_php_def(com, rel);

                if (com->api_format() >= 39)
                    send_python_def(com, rel);
            }

            send_idl_def(com, rel);
            break;

        case getUmlDefCmd:
            send_uml_def(com, rel);
            break;

        case getCppDefCmd:
            send_uml_def(com, rel);
            send_cpp_def(com, rel);
            break;

        case getJavaDefCmd:
            send_uml_def(com, rel);
            send_java_def(com, rel);
            break;

        case getPhpDefCmd:
            send_uml_def(com, rel);
            send_php_def(com, rel);
            break;

        case getPythonDefCmd:
            send_uml_def(com, rel);
            send_python_def(com, rel);
            break;

        case getIdlDefCmd:
            send_uml_def(com, rel);
            send_idl_def(com, rel);
            break;

        case sideCmd:
            if (*args)
                start->write_id(com);
            else if (end != 0)
                end->write_id(com);
            else
                com->write_id(0);

            break;

        default:
            return FALSE;
        }
    }

    return TRUE;
}
예제 #6
0
CMNode::CMNode(CMVariable* v) : CMAllocationUnit(v ? v->GetName() : L"",-1),
vmain(v),
vmonitorevaluated(0),
vmonitorresolved(0),
vmonitorcutback(0),
//vmonitorcarryover(0),
vmonitorgain(0),
vmonitorloss(0),
vmonitorput(0),
vmonitortake(0),
vmonitorshiftin(0),
vmonitorshiftout(0),
//vmonitorseasonalshift(0),
vmonitorfirststep(0),
vmonitorlaststep(0),
vmonitorpulls(0),
vmonitorage(0),
vcrank(0),
vcfloor(0),
vctrigger(0),
vcexpire(0),
vcfulltake(0),
vcfullput(0),
vccapacity(0),
vcmaxpulls(0),
ccutback(CM_BIGDOUBLE),
cput(CM_BIGDOUBLE),
ctake(CM_BIGDOUBLE),
cgain(0),
closs(0),
climit(CM_BIGDOUBLE),
storage_fifo(NULL),
state(0),
region(-1),
transfer_type(tSpot),
istriggered(0),
npulls(0),
maxpulls(0),
firststep(0),
laststep(0),
amtcut(0),
maxcut(0),
sumin(0),
sumout(0),
amtput(0),
amttake(0),
maxput(0),
maxtake(0)
{
	if (!v)	return;

   region = v->GetRegion();

	vtimestep = CMVariable::Find(L"_timestep");
	vmonitorevaluated = CMVariable::Find(v->GetName() + L".evaluated");
	vmonitorresolved = CMVariable::Find(v->GetName() + L".resolved");
	vmonitorcutback = CMVariable::Find(v->GetName() + L".cutback");
	//vmonitorcarryover = CMVariable::Find(v->GetName() + L".carryover");
	vmonitorgain = CMVariable::Find(v->GetName() + L".gain");
	vmonitorloss = CMVariable::Find(v->GetName() + L".loss");
	vmonitorput = CMVariable::Find(v->GetName() + L".put");
	vmonitortake = CMVariable::Find(v->GetName() + L".take");
	vmonitorshiftin = CMVariable::Find(v->GetName() + L".shiftin");
	vmonitorshiftout = CMVariable::Find(v->GetName() + L".shiftout");
	//vmonitorseasonalshift = CMVariable::Find(v->GetName() + L".seasonalshift");
	vmonitorfirststep = CMVariable::Find(v->GetName() + L".firstactivestep");
	vmonitorlaststep = CMVariable::Find(v->GetName() + L".lastactivestep");
	vmonitorpulls = CMVariable::Find(v->GetName() + L".pulls");
	vmonitorage = CMVariable::Find(v->GetName() + L".age");

	set_association(vcrank,L"rank");
	set_association(vcfloor,L"floor");
	set_association(vctrigger,L"trigger");
	set_association(vcexpire,L"expire");
	set_association(vccapacity,L"capacity");
	set_association(vcfulltake,L"fulltake");
	set_association(vcfullput,L"fullput");
	set_association(vcmaxpulls,L"maxpulls");

	ccutback.Set(v->GetAssociation(L"cutback"));
	cput.Set(v->GetAssociation(L"put"));
	ctake.Set(v->GetAssociation(L"take"));
	cgain.Set(v->GetAssociation(L"gain"));
	closs.Set(v->GetAssociation(L"loss"));
	climit.Set(v->GetAssociation(L"limit"));

   if (v->IsType(L"demand")) allocation_type = aDemand;
   else if (v->IsType(L"supply")) allocation_type = aSupply;
   else if (v->IsType(L"transfer")) allocation_type = aTransfer;
   else if (v->IsType(L"storage")) {
   	allocation_type = aStorage;
		storage_fifo = new CMFifo();
      v->SetState(CMVariable::vsCarryForward,TRUE);
		vmonitorresolved->SetState(CMVariable::vsCarryForward,TRUE);
		if (v->IsType(L"ageall")) state |= sAgeAll;
   }

	transfer_type = tCore;
	if (vmain->IsType(L"spot"))			  transfer_type = tSpot;
	else if (vmain->IsType(L"option"))  transfer_type = tOption;

	istriggered=0;
}