/*
// Do Not Remove this Comment:
//
// MESSAGES™ by XPLICIT COMPUTING, INC
// GOOGLE PROTOCOL BUFFER 3 DEFINITIONS
//
// Copyright 2020-2023 Xplicit Computing, Inc.
//
// Please see file README.md for usage and license info. README.md must be copied along
// with these *.proto as part of the license agreement. Direct questions or concerns to:
// info@xplicitcomputing.com
//
// SPDX-License-Identifier: BSD-3-Clause
// OSI-License-URL: https://opensource.org/licenses/BSD-3-Clause
*/ 



syntax = "proto3";

package Messages;

option cc_enable_arenas = true;                                                                         // faster memory allocation



message File
{
    string name = 1;
    bytes payload = 2;
    bool is_local = 3;
    bool is_exported = 4;
        //reserved
    uint64 time_created = 10;
    uint64 time_modified = 11; 
} 


message DirentNode
{
    string dirname = 1;
    repeated string files = 2;
    repeated DirentNode subdirs = 3;
}


message Revision
{
    uint64 major_rev = 1;
    uint64 minor_rev = 2;
}


message Extrema                                                                                         // domain bounds
{
    uint32 dims = 1;
    repeated double min = 2[packed=true];
    repeated double max = 3[packed=true];
    bool is_set = 4;
}

    
message Vector32                                                                                        // IEEE-754-compliant FP32 vector with embedded info, used extensively on client-side (and server visuals staging)
{
    string name = 1;
    uint32 components = 2;
    bool interleaved = 3;
    Revision revision = 4;
    string units = 5;                                                                                   // kg m s^2 and such string literals
    string comment = 6;
    //reserved
    uint64 offset = 9;                                                                                  // use to append (insert location to prior entries)
    repeated float values = 10[packed=true];
    repeated uint32 size_hint = 11[packed=true];
    //reserved
}


message Vector64                                                                                        // IEEE-754-compliant FP64 vector with embedded info, used extensively on server-side (and client input forms)
{
    string name = 1;
    uint32 components = 2;
    bool interleaved = 3;
    Revision revision = 4;
    string units = 5;                                                                                   // kg m s^2 and such string literals
    string comment = 6;
    //reserved
    uint64 offset = 9;                                                                                  // use to append (insert location to prior entries)
    repeated double values = 10[packed=true];
    repeated uint32 size_hint = 11[packed=true];
    //reserved
}


message SparseMatrix
{
    string name = 1;
    repeated uint32 size_hint = 2[packed=true];
    repeated uint32 indices = 3[packed=true];//1:1 mapping between indices and values
    repeated double values = 4[packed=true];
    Extrema bounds = 5;
}


message Rule // two forms: numerical or algorithmic requirement
{   //e.g. pk ( != | == | < | > ) value, else: execute algorithm(s)
    string pk = 1;                                                                       // serialized property-key <property|modifier|...>
    uint32 op = 2;                                                                       // either: comparator enum (requirement), or relative priority number in queue
    double value = 3;
    repeated string algorithms = 4;// names of algorithms to be associated
    repeated uint32 failed_nodes = 5[packed=true];
    repeated double failed_values = 6[packed=true];
}

message Record64
{
    string name = 1;
    string owner = 2;
    Revision revision = 3;
    //reserved
    uint32 length_units = 8;                        // 0-7: mm, cm, m, km, in, ft, yd, mi (defined in common/space.h)
    repeated Rule requirements = 9;
    repeated Vector64 data = 10;
    repeated SparseMatrix matrix = 11;
}


message UIndices
{
    string name = 1;
    uint32 components = 2;
    bool interleaved = 3;
    Revision revision = 4;
    //reserved
    uint64 offset = 9;                                                                                  // use to append (insert location to prior entries)
    repeated uint32 values = 10[packed=true];
}


message Elements                                                                                        // defined here to take advantage of packed arena allocation (only enabled within this proto file)
{
    repeated uint32 element_indices = 1[packed=true];                                                       // each element has a unique index assigned
    repeated uint32 element_types = 2[packed=true];                                                             // type convention (see xcompute-server documentation, enums for tri3, tet4, quad4, ... , tet 10, ...)
    repeated int32 element_ids = 3[packed=true];                                                                // region identifier (unique within a type of region, e.g. surface 0, surface 1, ..., volume 0, ... )
    repeated uint32 node_indices = 4[packed=true];                                                           // node indices (unique within this region, e.g. nodes 0, 1, 3, 5, 7 , 11, 13, 17 ... 41 ...)
    //reserved
    repeated double element_centers = 10[packed=true];                                                          // element barycenters, often computed as the average of node positions -- only required for nodes (optional for other element types)
    repeated double element_measures = 11[packed=true];                                                          // optional. element measure could be lengths (edges), areas (faces), or volumes (cells) values (scalar or nDim-component vector)
}
