+/**************************************************************************/
+/* ---------------------------------------------------------------------- */
+/* Copyright (C) 2006 - 2008 FRESCOR consortium partners: */
+/* */
+/* Universidad de Cantabria, SPAIN */
+/* University of York, UK */
+/* Scuola Superiore Sant'Anna, ITALY */
+/* Kaiserslautern University, GERMANY */
+/* Univ. Politécnica Valencia, SPAIN */
+/* Czech Technical University in Prague, CZECH REPUBLIC */
+/* ENEA SWEDEN */
+/* Thales Communication S.A. FRANCE */
+/* Visual Tools S.A. SPAIN */
+/* Rapita Systems Ltd UK */
+/* Evidence ITALY */
+/* */
+/* See http://www.frescor.org for a link to partners' websites */
+/* */
+/* FRESCOR project (FP6/2005/IST/5-034026) is funded */
+/* in part by the European Union Sixth Framework Programme */
+/* The European Union is not liable of any use that may be */
+/* made of this code. */
+/* */
+/* */
+/* This file is part of FRSH (FRescor ScHeduler) */
+/* */
+/* FRSH is free software; you can redistribute it and/or modify it */
+/* under terms of the GNU General Public License as published by the */
+/* Free Software Foundation; either version 2, or (at your option) any */
+/* later version. FRSH is distributed in the hope that it will be */
+/* useful, but WITHOUT ANY WARRANTY; without even the implied warranty */
+/* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
+/* General Public License for more details. You should have received a */
+/* copy of the GNU General Public License along with FRSH; see file */
+/* COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, */
+/* Cambridge, MA 02139, USA. */
+/* */
+/* As a special exception, including FRSH header files in a file, */
+/* instantiating FRSH generics or templates, or linking other files */
+/* with FRSH objects to produce an executable application, does not */
+/* by itself cause the resulting executable application to be covered */
+/* by the GNU General Public License. This exception does not */
+/* however invalidate any other reasons why the executable file might be */
+/* covered by the GNU Public License. */
+/**************************************************************************/
+
/**
* @file fres_contract.h
* @author Michal Sojka <sojkam1@fel.cvut.cz>
#include <fres_contract_type.h>
#include <fres_contract_idl.h>
#include <forb/server_id.h>
+#include <stdio.h>
#ifdef __cplusplus
extern "C" {
(forb_server_id*)b);
}
+static inline bool fres_contract_id_is_empty(const fres_contract_id_t *id)
+{
+/* bool empty = true; */
+/* unsigned i; */
+
+/* for (i=0; i<sizeof(id->byte); i++) { */
+/* if (id->byte[i] != 0) { */
+/* empty = false; */
+/* break; */
+/* } */
+/* } */
+/* return empty; */
+ return *id == 0;
+}
+
static inline char *fres_contract_id_to_string(char *dest,
const fres_contract_id_t *id,
size_t n)
{
- return forb_server_id_to_string(dest, (forb_server_id*)id, n);
+ snprintf(dest, n, "%llx", *id);
+/* return forb_server_id_to_string(dest, (forb_server_id*)id, n); */
+ return dest;
}
struct fres_contract *fres_contract_new(void);
void fres_contract_destroy(struct fres_contract *contract);
+
+/** Destructor for easy use in forb_sequence_free() */
+static inline void fres_contract_ptr_destroy(struct fres_contract **p)
+{
+ fres_contract_destroy(*p);
+}
+
+
struct fres_contract *fres_contract_duplicate(struct fres_contract *src);
/**
int
fres_contract_to_string(char *dest, size_t size, const struct fres_contract *c);
+/* #define FRES_C2S_FL_FMT_ONELINE */
+/* #define FRES_C2S_FL_FMT_BLOCKPERLINE */
+int
+fres_contract_to_string2(char *dest, size_t size, const struct fres_contract *c, int indent, uint32_t flags);
+
bool
fres_contract_get_deadline(const frsh_contract_t *contract,
frsh_rel_time_t *deadline);
+bool
+fres_contract_get_budget(const frsh_contract_t *contract,
+ frsh_rel_time_t *budget);
+bool
+fres_contract_get_period(const frsh_contract_t *contract,
+ frsh_rel_time_t *period);
+frsh_contract_type_t
+fres_contract_get_type(const frsh_contract_t *contract);
+
void
fres_contract_print(char *prefix, const struct fres_contract *c);
+static inline int
+fres_contract_get_num_blocks(const struct fres_contract *c)
+{
+ return fres_container_get_num_blocks(c->container);
+}
+
+static inline int
+fres_contract_merge(struct fres_contract *dest,
+ const struct fres_contract *src)
+{
+ return fres_container_merge(dest->container, src->container);
+}
+
+
/**
* Macro which defines type-safe contract "accessor" functions for
* various blocks.
FRES_CONTRACT_ACCESSOR(resource)
FRES_CONTRACT_ACCESSOR(basic)
FRES_CONTRACT_ACCESSOR(timing_reqs)
+FRES_CONTRACT_ACCESSOR(csects)
FRES_CONTRACT_ACCESSOR(spare_capacity)
+FRES_CONTRACT_ACCESSOR(power_management)
#ifdef __cplusplus
} /* extern "C"*/