- THROW_UNIMPLEMENTED;
-}
-
-}
-}
-
-/************
- * Resource *
- ************/
-
-namespace simgrid {
-namespace surf {
-
-Resource::Resource(Model *model, const char *name)
- : Resource(model, name, 1/*ON*/)
-{}
-
-Resource::Resource(Model *model, const char *name, lmm_constraint_t constraint)
- : Resource(model, name, constraint, 1/*ON*/)
-{}
-
-Resource::Resource(Model *model, const char *name, lmm_constraint_t constraint, int initiallyOn)
- : p_name(xbt_strdup(name))
- , p_model(model)
- , m_isOn(initiallyOn)
- , p_constraint(constraint)
-{}
-
-Resource::Resource(Model *model, const char *name, int initiallyOn)
- : p_name(xbt_strdup(name))
- , p_model(model)
- , m_isOn(initiallyOn)
-{}
-
-
-Resource::~Resource() {
- xbt_free((void*)p_name);
-}
-
-bool Resource::isOn() {
- return m_isOn;
-}
-bool Resource::isOff() {
- return ! m_isOn;
-}
-
-void Resource::turnOn()
-{
- if (!m_isOn) {
- m_isOn = true;
- }
-}
-
-void Resource::turnOff()
-{
- if (m_isOn) {
- m_isOn = false;
- }
-}
-
-Model *Resource::getModel() {
- return p_model;
-}
-
-const char *Resource::getName() {
- return p_name;
-}
-
-lmm_constraint_t Resource::getConstraint() {
- return p_constraint;
-}
-
-}
-}
-
-/**********
- * Action *
- **********/
-
-const char *surf_action_state_names[6] = {
- "SURF_ACTION_READY",
- "SURF_ACTION_RUNNING",
- "SURF_ACTION_FAILED",
- "SURF_ACTION_DONE",
- "SURF_ACTION_TO_FREE",
- "SURF_ACTION_NOT_IN_THE_SYSTEM"
-};
-
-/* added to manage the communication action's heap */
-void surf_action_lmm_update_index_heap(void *action, int i) {
- static_cast<simgrid::surf::Action*>(action)->updateIndexHeap(i);
-}
-
-namespace simgrid {
-namespace surf {
-
-void Action::initialize(simgrid::surf::Model *model, double cost, bool failed,
- lmm_variable_t var)
-{
- m_remains = cost;
- m_start = surf_get_clock();
- m_cost = cost;
- p_model = model;
- p_variable = var;
- if (failed)
- p_stateSet = getModel()->getFailedActionSet();
- else
- p_stateSet = getModel()->getRunningActionSet();
-
- p_stateSet->push_back(*this);
-}
-
-Action::Action(simgrid::surf::Model *model, double cost, bool failed)
-{
- initialize(model, cost, failed);
-}
-
-Action::Action(simgrid::surf::Model *model, double cost, bool failed, lmm_variable_t var)
-{
- initialize(model, cost, failed, var);
-}
-
-Action::~Action() {
- xbt_free(p_category);
-}
-
-void Action::finish() {
- m_finish = surf_get_clock();
-}
-
-e_surf_action_state_t Action::getState()
-{
- if (p_stateSet == getModel()->getReadyActionSet())
- return SURF_ACTION_READY;
- if (p_stateSet == getModel()->getRunningActionSet())
- return SURF_ACTION_RUNNING;
- if (p_stateSet == getModel()->getFailedActionSet())
- return SURF_ACTION_FAILED;
- if (p_stateSet == getModel()->getDoneActionSet())
- return SURF_ACTION_DONE;
- return SURF_ACTION_NOT_IN_THE_SYSTEM;
-}
-
-void Action::setState(e_surf_action_state_t state)
-{
- //surf_action_state_t action_state = &(action->model_type->states);
- XBT_IN("(%p,%s)", this, surf_action_state_names[state]);
- p_stateSet->erase(p_stateSet->iterator_to(*this));
- if (state == SURF_ACTION_READY)
- p_stateSet = getModel()->getReadyActionSet();
- else if (state == SURF_ACTION_RUNNING)
- p_stateSet = getModel()->getRunningActionSet();
- else if (state == SURF_ACTION_FAILED)
- p_stateSet = getModel()->getFailedActionSet();
- else if (state == SURF_ACTION_DONE)
- p_stateSet = getModel()->getDoneActionSet();
- else
- p_stateSet = NULL;
-
- if (p_stateSet)
- p_stateSet->push_back(*this);
- XBT_OUT();
-}
-
-double Action::getBound()
-{
- return (p_variable) ? lmm_variable_getbound(p_variable) : 0;
-}
-
-void Action::setBound(double bound)
-{
- XBT_IN("(%p,%g)", this, bound);
- if (p_variable)
- lmm_update_variable_bound(getModel()->getMaxminSystem(), p_variable, bound);
-
- if (getModel()->getUpdateMechanism() == UM_LAZY && getLastUpdate()!=surf_get_clock())
- heapRemove(getModel()->getActionHeap());
- XBT_OUT();
-}
-
-double Action::getStartTime()
-{
- return m_start;
-}
-
-double Action::getFinishTime()
-{
- /* keep the function behavior, some models (cpu_ti) change the finish time before the action end */
- return m_remains == 0 ? m_finish : -1;
-}
-
-void Action::setData(void* data)
-{
- p_data = data;
-}
-
-void Action::setCategory(const char *category)
-{
- XBT_IN("(%p,%s)", this, category);
- p_category = xbt_strdup(category);
- XBT_OUT();
-}
-
-void Action::ref(){
- m_refcount++;
-}
-
-void Action::setMaxDuration(double duration)
-{
- XBT_IN("(%p,%g)", this, duration);
- m_maxDuration = duration;
- if (getModel()->getUpdateMechanism() == UM_LAZY) // remove action from the heap
- heapRemove(getModel()->getActionHeap());
- XBT_OUT();