MicroModelicaCCompiler  4.5.3
graph_profile.cpp
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  This file is part of QSS Solver.
4 
5  QSS Solver is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  QSS Solver is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with QSS Solver. If not, see <http://www.gnu.org/licenses/>.
17 
18  ******************************************************************************/
19 
20 #include <stdlib.h>
21 
22 #include "graph_profile.hpp"
23 
25 {
26  if (type == GRP_CONT) {
27  return g->state->contEdgeWeight;
28  } else if (type == GRP_DSC) {
29  return g->state->dscEdgeWeight;
30  } else {
31  return g->state->virtEdgeWeight;
32  }
33  return 0;
34 }
35 
37 {
38  GRP_graphProfile p = (GRP_graphProfile)malloc(sizeof(*p));
39  p->ops = GRP_GraphProfileOps();
41  return p;
42 }
43 
45 {
48  free(g);
49 }
50 
52 {
53  GRP_graphProfileOps p = (GRP_graphProfileOps)malloc(sizeof(*p));
55  return p;
56 }
57 
59 
61 {
62  GRP_graphProfileState p = (GRP_graphProfileState)malloc(sizeof(*p));
63  p->states = 0;
64  p->events = 0;
65  p->contEdgeWeight = 10;
66  p->dscEdgeWeight = 10;
67  p->virtEdgeWeight = 1;
68  return p;
69 }
70 
72 
73 double GRP_Weight(GRP_graphProfile g, GRP_EdgeType type) { return g->ops->weight(g, type); }
GRP_graphProfileState_::events
int events
Definition: graph_profile.hpp:60
GRP_GraphProfileState
GRP_graphProfileState GRP_GraphProfileState()
Definition: graph_profile.cpp:60
GRP_GraphProfile
GRP_graphProfile GRP_GraphProfile()
Definition: graph_profile.cpp:36
GRP_graphProfileState_::states
int states
Definition: graph_profile.hpp:59
GRP_graphProfileState
struct GRP_graphProfileState_ * GRP_graphProfileState
Definition: graph_profile.hpp:33
GRP_Weight
double GRP_Weight(GRP_graphProfile g, GRP_EdgeType type)
Definition: graph_profile.cpp:73
GRP_graphProfile
struct GRP_graphProfile_ * GRP_graphProfile
Definition: graph_profile.hpp:38
GRP_graphProfileState_::contEdgeWeight
double contEdgeWeight
Definition: graph_profile.hpp:61
GRP_nodeWeight
double GRP_nodeWeight(GRP_graphProfile g, GRP_EdgeType type)
Definition: graph_profile.cpp:24
GRP_graphProfileOps_::weight
GRP_graphProfileWeight weight
Definition: graph_profile.hpp:52
GRP_freeGraphProfileState
void GRP_freeGraphProfileState(GRP_graphProfileState state)
Definition: graph_profile.cpp:71
GRP_GraphProfileOps
GRP_graphProfileOps GRP_GraphProfileOps()
Definition: graph_profile.cpp:51
graph_profile.hpp
GRP_freeGraphProfile
void GRP_freeGraphProfile(GRP_graphProfile g)
Definition: graph_profile.cpp:44
GRP_CONT
@ GRP_CONT
Definition: graph_profile.hpp:40
GRP_graphProfileState_::virtEdgeWeight
double virtEdgeWeight
Definition: graph_profile.hpp:63
GRP_graphProfileOps_
Definition: graph_profile.hpp:51
GRP_EdgeType
GRP_EdgeType
Definition: graph_profile.hpp:23
GRP_DSC
@ GRP_DSC
Definition: graph_profile.hpp:40
GRP_graphProfileOps
struct GRP_graphProfileOps_ * GRP_graphProfileOps
Definition: graph_profile.hpp:28
GRP_freeGraphProfileOps
void GRP_freeGraphProfileOps(GRP_graphProfileOps ops)
Definition: graph_profile.cpp:58
GRP_graphProfileState_::dscEdgeWeight
double dscEdgeWeight
Definition: graph_profile.hpp:62
GRP_graphProfile_::ops
GRP_graphProfileOps ops
Definition: graph_profile.hpp:70
GRP_graphProfile_::state
GRP_graphProfileState state
Definition: graph_profile.hpp:71
GRP_graphProfile_
Definition: graph_profile.hpp:69
GRP_graphProfileState_
Definition: graph_profile.hpp:58