Introduced classes

Redefined classes

redef class APIRouter

nitc :: api_metrics $ APIRouter

A Rooter dedicated to APIHandlers.
redef class FloatMetric

nitc :: api_metrics $ FloatMetric

A Metric that collects float datas
redef class IntMetric

nitc :: api_metrics $ IntMetric

A Metric that collects integer data
redef class MClass

nitc :: api_metrics $ MClass

A named class
redef abstract class MClassMetric

nitc :: api_metrics $ MClassMetric

A metric about MClass
redef abstract class MEntity

nitc :: api_metrics $ MEntity

A named and possibly documented entity in the model.
redef class MGroup

nitc :: api_metrics $ MGroup

A group of modules in a package
redef class MModule

nitc :: api_metrics $ MModule

A Nit module is usually associated with a Nit source file.
redef abstract class MModuleMetric

nitc :: api_metrics $ MModuleMetric

A metric about MModule
redef class MPackage

nitc :: api_metrics $ MPackage

A Nit package, that encompass a product
redef interface Metric

nitc :: api_metrics $ Metric

A Metric is used to collect data about things
redef class MetricSet

nitc :: api_metrics $ MetricSet

A MetricSet is a metric holder

All class definitions

redef class APIRouter

nitc :: api_metrics $ APIRouter

A Rooter dedicated to APIHandlers.
redef class FloatMetric

nitc :: api_metrics $ FloatMetric

A Metric that collects float datas
redef class IntMetric

nitc :: api_metrics $ IntMetric

A Metric that collects integer data
redef class MClass

nitc :: api_metrics $ MClass

A named class
redef abstract class MClassMetric

nitc :: api_metrics $ MClassMetric

A metric about MClass
redef abstract class MEntity

nitc :: api_metrics $ MEntity

A named and possibly documented entity in the model.
redef class MGroup

nitc :: api_metrics $ MGroup

A group of modules in a package
redef class MModule

nitc :: api_metrics $ MModule

A Nit module is usually associated with a Nit source file.
redef abstract class MModuleMetric

nitc :: api_metrics $ MModuleMetric

A metric about MModule
redef class MPackage

nitc :: api_metrics $ MPackage

A Nit package, that encompass a product
redef interface Metric

nitc :: api_metrics $ Metric

A Metric is used to collect data about things
private class MetricEntry

nitc $ MetricEntry

redef class MetricSet

nitc :: api_metrics $ MetricSet

A MetricSet is a metric holder
package_diagram nitc::api_metrics api_metrics nitc::api_base api_base nitc::api_metrics->nitc::api_base nitc\>metrics\> metrics nitc::api_metrics->nitc\>metrics\> popcorn popcorn nitc::api_base->popcorn popcorn::pop_repos pop_repos nitc::api_base->popcorn::pop_repos popcorn::pop_json pop_json nitc::api_base->popcorn::pop_json nitc::commands_http commands_http nitc::api_base->nitc::commands_http nitc::json_commands json_commands nitc::api_base->nitc::json_commands nitc::html_commands html_commands nitc::api_base->nitc::html_commands nitc\>semantize\> semantize nitc\>metrics\>->nitc\>semantize\> nitc\>model\> model nitc\>metrics\>->nitc\>model\> nitc\>frontend\> frontend nitc\>metrics\>->nitc\>frontend\> nitc\>modelize\> modelize nitc\>metrics\>->nitc\>modelize\> nitc nitc nitc\>metrics\>->nitc csv csv nitc\>metrics\>->csv counter counter nitc\>metrics\>->counter markdown2 markdown2 nitc\>metrics\>->markdown2 ...popcorn ... ...popcorn->popcorn ...popcorn::pop_repos ... ...popcorn::pop_repos->popcorn::pop_repos ...popcorn::pop_json ... ...popcorn::pop_json->popcorn::pop_json ...nitc::commands_http ... ...nitc::commands_http->nitc::commands_http ...nitc::json_commands ... ...nitc::json_commands->nitc::json_commands ...nitc::html_commands ... ...nitc::html_commands->nitc::html_commands ...nitc\>semantize\> ... ...nitc\>semantize\>->nitc\>semantize\> ...nitc\>model\> ... ...nitc\>model\>->nitc\>model\> ...nitc\>frontend\> ... ...nitc\>frontend\>->nitc\>frontend\> ...nitc\>modelize\> ... ...nitc\>modelize\>->nitc\>modelize\> ...nitc ... ...nitc->nitc ...csv ... ...csv->csv ...counter ... ...counter->counter ...markdown2 ... ...markdown2->markdown2 nitc::api api nitc::api->nitc::api_metrics nitc::nitweb nitweb nitc::nitweb->nitc::api nitc::nitweb... ... nitc::nitweb...->nitc::nitweb

Ancestors

module abstract_collection

core :: abstract_collection

Abstract collection classes and services.
module abstract_text

core :: abstract_text

Abstract class for manipulation of sequences of characters
module abstract_tree

trees :: abstract_tree

Introduce tree structures abstraction
module actors_injection_phase

nitc :: actors_injection_phase

Injects model for the classes annotated with "is actor" so
module annotation

nitc :: annotation

Management and utilities on annotations
module array

core :: array

This module introduces the standard array structure.
module ast_metrics

nitc :: ast_metrics

Metrics about the nodes and identifiers in the AST
module astbuilder

nitc :: astbuilder

Instantiation and transformation of semantic nodes in the AST of expressions and statements
module astutil

nitc :: astutil

Additional features on Nit AST
module auto_super_init

nitc :: auto_super_init

Computing of super-constructors that must be implicitly called at the begin of constructors.
module base64

base64 :: base64

Offers the base 64 encoding and decoding algorithms
module bintree

trees :: bintree

Binary Tree data-structure
module bitset

core :: bitset

Services to handle BitSet
module bktree

trees :: bktree

Implementation of BKTree
module bootstrap

html :: bootstrap

HTML templates for Bootstrap components.
module bytes

core :: bytes

Services for byte streams and arrays
module c

c :: c

Structures and services for compatibility with the C language
module caching

serialization :: caching

Services for caching serialization engines
module catalog

nitc :: catalog

Basic catalog generator for Nit packages
module check_annotation

nitc :: check_annotation

Check that annotation present in the AST are either primitive or user-declared
module circular_array

core :: circular_array

Efficient data structure to access both end of the sequence.
module codec_base

core :: codec_base

Base for codecs to use with streams
module codecs

core :: codecs

Group module for all codec-related manipulations
module collection

core :: collection

This module define several collection classes.
module commands_base

nitc :: commands_base

Documentation commands
module commands_catalog

nitc :: commands_catalog

Commands to retrieve Catalog related data
module commands_docdown

nitc :: commands_docdown

Doc down related queries
module commands_graph

nitc :: commands_graph

Graph commands
module commands_http

nitc :: commands_http

Initialize commands from HTTP requests
module commands_model

nitc :: commands_model

Doc commands about a Model or a MEntity
module commands_parser

nitc :: commands_parser

A parser that create DocCommand from a string
module commands_usage

nitc :: commands_usage

Commands about how mentities are used
module config

config :: config

Configuration options for nit tools and apps
module console

console :: console

Defines some ANSI Terminal Control Escape Sequences.
module core

core :: core

Standard classes and methods used by default by Nit programs and libraries.
module counter

counter :: counter

Simple numerical statistical analysis and presentation
module csv

csv :: csv

CSV document handling.
module deriving

nitc :: deriving

Injection of automatic method definitions for standard methods, based on the attributes of the classes
module detect_covariance

nitc :: detect_covariance

Detect the static usage of covariance in the code.
module detect_variance_constraints

nitc :: detect_variance_constraints

Collect metrics about detected variances constraints on formal types.
module digraph

graph :: digraph

Implementation of directed graphs, also called digraphs.
module div_by_zero

nitc :: div_by_zero

Detection of divisions by zero in obvious cases
module dot

dot :: dot

Dot rendering library
module engine_tools

serialization :: engine_tools

Advanced services for serialization engines
module environ

core :: environ

Access to the environment variables of the process
module error

json :: error

Intro JsonParseError which is exposed by all JSON reading APIs
module error

core :: error

Standard error-management infrastructure.
module exec

core :: exec

Invocation and management of operating system sub-processes.
module explain_assert_api

nitc :: explain_assert_api

Explain failed assert to the console (service declaration only)
module file

core :: file

File manipulations (create, read, write, etc.)
module file_server

nitcorn :: file_server

Provides the FileServer action, which is a standard and minimal file server
module fixed_ints

core :: fixed_ints

Basic integers of fixed-precision
module fixed_ints_text

core :: fixed_ints_text

Text services to complement fixed_ints
module flat

core :: flat

All the array-based text representations
module flow

nitc :: flow

Intraprocedural static flow.
module frontend

nitc :: frontend

Collect and orchestration of main frontend phases
module gc

core :: gc

Access to the Nit internal garbage collection mechanism
module generate_hierarchies

nitc :: generate_hierarchies

Create dot files for various hierarchies of a model.
module glsl_validation

nitc :: glsl_validation

Check shader code within Nit modules using the tool glslangValidator
module hash_collection

core :: hash_collection

Introduce HashMap and HashSet.
module highlight

nitc :: highlight

Highlighting of Nit AST
module html

html :: html

HTML output facilities
module html_commands

nitc :: html_commands

Render commands results as HTML
module html_model

nitc :: html_model

Translate mentities to html blocks.
module htmlight

nitc :: htmlight

Highlighting of Nit AST with HTML
module http_errors

nitcorn :: http_errors

Offers ErrorTemplate to display error pages
module http_request

nitcorn :: http_request

Provides the HttpRequest class and services to create it
module http_request_buffer

nitcorn :: http_request_buffer

Http request parsing for buffered inputs.
module http_response

nitcorn :: http_response

Provides the HttpResponse class and http_status_codes
module i18n_phase

nitc :: i18n_phase

Basic support of internationalization through the generation of id-to-string tables
module inheritance_metrics

nitc :: inheritance_metrics

Collect metrics about inheritance usage
module ini

ini :: ini

Read and write INI configuration files
module inspect

serialization :: inspect

Refine Serializable::inspect to show more useful information
module iso8859_1

core :: iso8859_1

Codec for ISO8859-1 I/O
module json

json :: json

Read and write JSON formatted text using the standard serialization services
module json_commands

nitc :: json_commands

Translate command results to json
module json_model

nitc :: json_model

Make model entities Serializable.
module kernel

core :: kernel

Most basic classes and methods.
module lexer

nitc :: lexer

Lexer and its tokens.
module lexer_work

nitc :: lexer_work

Internal algorithm and data structures for the Nit lexer
module libevent

libevent :: libevent

Low-level wrapper around the libevent library to manage events on file descriptors
module list

core :: list

This module handle double linked lists
module literal

nitc :: literal

Parsing of literal values in the abstract syntax tree.
module loader

nitc :: loader

Loading of Nit source files
module local_var_init

nitc :: local_var_init

Verify that local variables are initialized before their usage
module location

nitc :: location

Nit source-file and locations in source-file
module logger

logger :: logger

A simple logger for Nit
module markdown

markdown :: markdown

Markdown parsing.
module markdown_ast

markdown2 :: markdown_ast

Markdown AST representation
module markdown_block_parsing

markdown2 :: markdown_block_parsing

Markdown blocks parsing
module markdown_github

markdown2 :: markdown_github

Markdown Github mode
module markdown_html_rendering

markdown2 :: markdown_html_rendering

HTML rendering of Markdown documents
module markdown_inline_parsing

markdown2 :: markdown_inline_parsing

Parser for inline markdown
module markdown_rendering

markdown2 :: markdown_rendering

Markdown document rendering
module math

core :: math

Mathematical operations
module mclasses_metrics

nitc :: mclasses_metrics

Collect common metrics about mclasses
module md5

md5 :: md5

Native MD5 digest implementation as Text::md5
module md_commands

nitc :: md_commands

Render commands results as Markdown
module mdoc

nitc :: mdoc

Documentation of model entities
module media_types

nitcorn :: media_types

Services to identify Internet media types (or MIME types, Content-types)
module mendel_metrics

nitc :: mendel_metrics

The Mendel model helps to understand class hierarchies.
module meta

meta :: meta

Simple user-defined meta-level to manipulate types of instances as object.
module metrics_base

nitc :: metrics_base

Helpers for various statistics tools.
module mmodule

nitc :: mmodule

modules and module hierarchies in the metamodel
module mmodule_data

nitc :: mmodule_data

Define and retrieve data in modules
module mmodules_metrics

nitc :: mmodules_metrics

Collect common metrics about modules
module model

nitc :: model

Classes, types and properties
module model_base

nitc :: model_base

The abstract concept of model and related common things
module model_collect

nitc :: model_collect

Collect things from the model.
module model_examples

nitc :: model_examples

Examples for Model entities
module model_hyperdoc

nitc :: model_hyperdoc

Dump of Nit model into hypertext human-readable format.
module model_index

nitc :: model_index

Search things from the Model
module model_viz

nitc :: model_viz

Visualisation of Nit models
module modelbuilder_base

nitc :: modelbuilder_base

Load nit source files and build the associated model
module modelize

nitc :: modelize

Create a model from nit source files
module modelize_class

nitc :: modelize_class

Analysis and verification of class definitions to instantiate model element
module modelize_property

nitc :: modelize_property

Analysis and verification of property definitions to instantiate model element
module mongodb

mongodb :: mongodb

MongoDB Nit Driver.
module more_collections

more_collections :: more_collections

Highly specific, but useful, collections-related classes.
module mpackage

nitc :: mpackage

Modelisation of a Nit package
module native

core :: native

Native structures for text and bytes
module native_mongodb

mongodb :: native_mongodb

Native wrapper for the MongoDB C Driver
module nitcorn

nitcorn :: nitcorn

The nitcorn Web server framework creates server-side Web apps in Nit
module nitpm_shared

nitc :: nitpm_shared

Services related to the Nit package manager
module no_warning

nitc :: no_warning

Fill toolcontext information about blacklisting of warnings.
module nullables_metrics

nitc :: nullables_metrics

Statistics about the usage of nullables
module numeric

core :: numeric

Advanced services for Numeric types
module opts

opts :: opts

Management of options on the command line
module ordered_tree

ordered_tree :: ordered_tree

Manipulation and presentation of ordered trees.
module parallelization_phase

nitc :: parallelization_phase

Phase generating threads for functions annotated with threaded annotation
module parse_annotations

nitc :: parse_annotations

Simple annotation parsing
module parser

nitc :: parser

Parser.
module parser_base

parser_base :: parser_base

Simple base for hand-made parsers of all kinds
module parser_nodes

nitc :: parser_nodes

AST nodes of the Nit language
module parser_prod

nitc :: parser_prod

Production AST nodes full definition.
module parser_util

nitc :: parser_util

Utils and tools related to parsers and AST
module parser_work

nitc :: parser_work

Internal algorithm and data structures for the Nit parser
module phase

nitc :: phase

Phases of the processing of nit programs
module pipeline

pipeline :: pipeline

Pipelined filters and operations on iterators.
module pop_config

popcorn :: pop_config

Configuration file and options for Popcorn apps
module pop_handlers

popcorn :: pop_handlers

Route handlers.
module pop_json

popcorn :: pop_json

Introduce useful services for JSON REST API handlers.
module pop_repos

popcorn :: pop_repos

Repositories for data management.
module pop_routes

popcorn :: pop_routes

Internal routes representation.
module pop_sessions

popcorn :: pop_sessions

Session handlers
module pop_tasks

popcorn :: pop_tasks

Popcorn threaded tasks
module pop_validation

popcorn :: pop_validation

Quick and easy validation framework for Json inputs
module popcorn

popcorn :: popcorn

Application server abstraction on top of nitcorn.
module poset

poset :: poset

Pre order sets and partial order set (ie hierarchies)
module poset_metrics

nitc :: poset_metrics

Metrics about the various posets of the model of a Nit program
module protocol

core :: protocol

module pthreads

pthreads :: pthreads

Main POSIX threads support and intro the classes Thread, Mutex and Barrier
module queries

mongodb :: queries

Mongo queries framework
module queue

core :: queue

Queuing data structures and wrappers
module range

core :: range

Module for range of discrete objects.
module rapid_type_analysis

nitc :: rapid_type_analysis

Rapid type analysis on the AST
module rbtree

trees :: rbtree

A red–black tree is a data structure which is a type of self-balancing binary search tree.
module re

core :: re

Regular expression support for all services based on Pattern
module reactor

nitcorn :: reactor

Core of the nitcorn project, provides HttpFactory and Action
module readme_metrics

nitc :: readme_metrics

Collect common metrics about README files
module realtime

realtime :: realtime

Services to keep time of the wall clock time
module refinement_metrics

nitc :: refinement_metrics

Collect metrics about refinement usage
module regex_phase

nitc :: regex_phase

Check for error in regular expressions from string literals
module ropes

core :: ropes

Tree-based representation of a String.
module rta_metrics

nitc :: rta_metrics

Metrics from RTA
module safe

serialization :: safe

Services for safer deserialization engines
module scope

nitc :: scope

Identification and scoping of local variables and labels.
module self_metrics

nitc :: self_metrics

Metrics about the usage of explicit and implicit self
module semantize

nitc :: semantize

Process bodies of methods in regard with the model.
module serialization

serialization :: serialization

General serialization services
module serialization_core

serialization :: serialization_core

Abstract services to serialize Nit objects to different formats
module serialization_model_phase

nitc :: serialization_model_phase

Phase generating methods (model-only) to serialize Nit objects
module serialization_read

json :: serialization_read

Services to read JSON: deserialize_json and JsonDeserializer
module serialization_write

json :: serialization_write

Services to write Nit objects to JSON strings: serialize_to_json and JsonSerializer
module server_config

nitcorn :: server_config

Classes and services to configure the server
module sessions

nitcorn :: sessions

Automated session management
module signal_handler

nitcorn :: signal_handler

Handle SIGINT and SIGTERM to close the server after all active events
module simple_misc_analysis

nitc :: simple_misc_analysis

Simple vavious processing on a AST
module sorter

core :: sorter

This module contains classes used to compare things and sorts arrays.
module static

json :: static

Static interface to read Nit objects from JSON strings
module static_types_metrics

nitc :: static_types_metrics

Metrics on the usage of explicit static types.
module stream

core :: stream

Input and output streams of characters
module tables

nitc :: tables

Module that interfaces the parsing tables.
module tables_metrics

nitc :: tables_metrics

Metrics on table generation
module template

template :: template

Basic template system
module text

core :: text

All the classes and methods related to the manipulation of text entities
module time

core :: time

Management of time and dates
module token

nitcorn :: token

Simple generate_token service, independent of the rest of the nitcorn framework
module toolcontext

nitc :: toolcontext

Common command-line tool infrastructure than handle options and error messages
module trees

trees :: trees

General module for tree data structures
module trie

trees :: trie

A trie (or prefix tree) is a datastructure used to perform prefix searches.
module typing

nitc :: typing

Intraprocedural resolution of static types and OO-services
module uml

nitc :: uml

Group head module for UML generation services
module uml_base

nitc :: uml_base

Exposes the base class for UML generation of a Model
module uml_class

nitc :: uml_class

Provides facilities of exporting a Model to a UML class diagram
module uml_module

nitc :: uml_module

Services for generation of a UML package diagram based on a Model
module union_find

core :: union_find

union–find algorithm using an efficient disjoint-set data structure
module utf8

core :: utf8

Codec for UTF-8 I/O
module vararg_routes

nitcorn :: vararg_routes

Routes with parameters.
module version

nitc :: version

This file was generated by git-gen-version.sh

Parents

module api_base

nitc :: api_base

Base classes used by nitweb.
module metrics

nitc :: metrics

Various statistics about Nit models and programs

Children

module api

nitc :: api

Components required to build a web server about the nit model.

Descendants

module a_star-m

a_star-m

module nitweb

nitc :: nitweb

Runs a webserver based on nitcorn that render things from model.
module api_metrics

import api_base
import metrics

redef class APIRouter
	redef init do
		super
		use("/metrics/structural/:id", new APIStructuralMetrics(config))
	end
end

class APIStructuralMetrics
	super APIHandler

	private fun mclasses_metrics: MetricSet do
		var metrics = new MetricSet
		metrics.register(new CNOA(config.model, config.mainmodule, config.filter))
		metrics.register(new CNOP(config.model, config.mainmodule, config.filter))
		metrics.register(new CNOC(config.model, config.mainmodule, config.filter))
		metrics.register(new CNOD(config.model, config.mainmodule, config.filter))
		metrics.register(new CNOAC(config.model, config.mainmodule, config.filter))
		metrics.register(new CNOAA(config.model, config.mainmodule, config.filter))
		metrics.register(new CNOAI(config.model, config.mainmodule, config.filter))
		metrics.register(new CDIT(config.model, config.mainmodule, config.filter))
		metrics.register(new CNBP(config.model, config.mainmodule, config.filter))
		metrics.register(new CNBA(config.model, config.mainmodule, config.filter))
		metrics.register(new CNBM(config.model, config.mainmodule, config.filter))
		metrics.register(new CNBI(config.model, config.mainmodule, config.filter))
		metrics.register(new CNBV(config.model, config.mainmodule, config.filter))
		metrics.register(new CNBIP(config.model, config.mainmodule, config.filter))
		metrics.register(new CNBRP(config.model, config.mainmodule, config.filter))
		metrics.register(new CNBHP(config.model, config.mainmodule, config.filter))
		metrics.register(new CNBLP(config.model, config.mainmodule, config.filter))
		return metrics
	end

	private fun mmodules_metrics: MetricSet do
		var metrics = new MetricSet
		metrics.register(new MNOA(config.model, config.mainmodule, config.filter))
		metrics.register(new MNOP(config.model, config.mainmodule, config.filter))
		metrics.register(new MNOC(config.model, config.mainmodule, config.filter))
		metrics.register(new MNOD(config.model, config.mainmodule, config.filter))
		metrics.register(new MDIT(config.model, config.mainmodule, config.filter))
		metrics.register(new MNBD(config.model, config.mainmodule, config.filter))
		metrics.register(new MNBI(config.model, config.mainmodule, config.filter))
		metrics.register(new MNBR(config.model, config.mainmodule, config.filter))
		metrics.register(new MNBCC(config.model, config.mainmodule, config.filter))
		metrics.register(new MNBAC(config.model, config.mainmodule, config.filter))
		return metrics
	end

	redef fun get(req, res) do
		var mentity = mentity_from_uri(req, res)
		if mentity == null then return
		var metrics = mentity.collect_metrics(self)
		if metrics == null then
			res.api_error(404, "No metric for mentity `{mentity.full_name}`")
			return
		end
		res.api_json(req, metrics)
	end
end

redef class MEntity
	private fun collect_metrics(h: APIStructuralMetrics): nullable JsonObject do return null
end

redef class MPackage
	redef fun collect_metrics(h) do
		var mclasses = new HashSet[MClass]
		for mgroup in self.mgroups do
			for mmodule in mgroup.mmodules do mclasses.add_all mmodule.intro_mclasses
		end

		var mclasses_metrics = h.mclasses_metrics
		mclasses_metrics.collect(new HashSet[MClass].from(mclasses))

		var mmodules = new HashSet[MModule]
		for mgroup in self.mgroups do
			mmodules.add_all mgroup.mmodules
		end

		var mmodules_metrics = h.mmodules_metrics
		mmodules_metrics.collect(new HashSet[MModule].from(mmodules))

		var metrics = new JsonObject
		metrics["mclasses"] = mclasses_metrics
		metrics["mmodules"] = mmodules_metrics
		return metrics
	end
end

redef class MGroup
	redef fun collect_metrics(h) do
		var mclasses = new HashSet[MClass]
		for mmodule in self.mmodules do mclasses.add_all mmodule.intro_mclasses

		var mclasses_metrics = h.mclasses_metrics
		mclasses_metrics.collect(new HashSet[MClass].from(mclasses))

		var mmodules_metrics = h.mmodules_metrics
		mmodules_metrics.collect(new HashSet[MModule].from(mmodules))

		var metrics = new JsonObject
		metrics["mclasses"] = mclasses_metrics
		metrics["mmodules"] = mmodules_metrics
		return metrics
	end
end

redef class MModule
	redef fun collect_metrics(h) do
		var mclasses_metrics = h.mclasses_metrics
		mclasses_metrics.collect(new HashSet[MClass].from(intro_mclasses))

		var mmodule_metrics = h.mmodules_metrics
		mmodule_metrics.collect(new HashSet[MModule].from([self]))

		var metrics = new JsonObject
		metrics["mclasses"] = mclasses_metrics
		metrics["mmodule"] = mmodule_metrics
		return metrics
	end
end

redef class MClass
	redef fun collect_metrics(h) do
		var mclass_metrics = h.mclasses_metrics
		mclass_metrics.collect(new HashSet[MClass].from([self]))

		var metrics = new JsonObject
		metrics["mclass"] = mclass_metrics
		return metrics
	end
end

redef class MetricSet
	super Serializable

	redef fun core_serialize_to(v) do
		for metric in metrics do
			v.serialize_attribute(metric.name, metric)
		end
	end
end

redef class Metric
	super Serializable

	redef fun core_serialize_to(v) do
		v.serialize_attribute("name", name)
		v.serialize_attribute("desc", desc)
		v.serialize_attribute("empty", values.is_empty)
		if values.not_empty then v.serialize_attribute("avg", avg)
		if values.not_empty then v.serialize_attribute("std_dev", std_dev)
		if values.not_empty then v.serialize_attribute("threshold", threshold)
	end
end

redef class IntMetric
	redef fun core_serialize_to(v) do
		super
		if values.not_empty then v.serialize_attribute("sum", sum)
	end
end

redef class FloatMetric
	redef fun core_serialize_to(v) do
		super
		if values.not_empty then v.serialize_attribute("sum", sum)
	end
end

redef class MModuleMetric
	redef fun core_serialize_to(v) do
		super
		if values.not_empty then v.serialize_attribute("min", min)
		if values.not_empty then v.serialize_attribute("max", max)
		var values = new JsonObject
		for value in sort do
			values[value.full_name] = new MetricEntry(value, self[value])
		end
		v.serialize_attribute("values", values)
	end
end

redef class MClassMetric
	redef fun core_serialize_to(v) do
		super
		if values.not_empty then v.serialize_attribute("min", min)
		if values.not_empty then v.serialize_attribute("max", max)
		var values = new JsonObject
		for value in sort do
			values[value.full_name] = new MetricEntry(value, self[value])
		end
		v.serialize_attribute("values", values)
	end
end

private class MetricEntry
	super Serializable

	var mentity: MEntity
	var value: Object

	redef fun core_serialize_to(v) do
		v.serialize_attribute("mentity", mentity)
		v.serialize_attribute("value", if value isa JsonObject then value else value.to_s)
	end
end
src/doc/api/api_metrics.nit:15,1--225,3