My Project
Loading...
Searching...
No Matches
Data Structures | Functions
countedref.h File Reference

This file defines reusable classes supporting reference counted interpreter objects and initiates the blackbox operations for high-level types 'reference' and 'shared'. More...

#include "omalloc/omalloc.h"
#include "kernel/structs.h"
#include "Singular/subexpr.h"
#include "Singular/idrec.h"
#include "Singular/ipid.h"

Go to the source code of this file.

Data Structures

class  CountedRefPtr< PtrType, Nondestructive, NeverNull, CountType >
 This class implements a smart pointer which handles pointer-style access to a reference-counted structure and destructing the latter after use. More...
 
class  RefCounter
 This class implements implements a refernce counter which we can use as a public base of objects managed by @CountedRefPtr. More...
 
class  CountedRefIndirectPtr< PtrType >
 
class  CountedRefWeakPtr< PtrType >
 
class  LeftvHelper
 This class implements some recurrent code sniplets to be used with leftv and idhdl.implements a refernce counter which we can use. More...
 
class  LeftvShallow
 Ths class wraps leftv by taking into acount memory allocation, destruction as well as shallowly copying of a given leftv, i.e. More...
 
class  LeftvDeep
 This class wraps leftv by taking into acount memory allocation, destruction as well as deeply copying of a given leftv, i.e. More...
 
struct  LeftvDeep::copy_tag
 Construct even deeper copy: Skip identifier (if any) and take care of the data on our own. More...
 

Functions

template<class PtrType >
void CountedRefPtr_kill (CountedRefIndirectPtr< PtrType > *pval)
 
void countedref_reference_load ()
 Initialize blackbox types 'reference' and 'shared', or both. More...
 
void countedref_shared_load ()
 
void countedref_init ()
 

Detailed Description

This file defines reusable classes supporting reference counted interpreter objects and initiates the blackbox operations for high-level types 'reference' and 'shared'.

Note
This works was supported by the "Industrial Algebra" project.
Author
Alexander Dreyer
Date
2012-08-15
Copyright:
(c) 2012 by The Singular Team, see LICENSE file

Definition in file countedref.h.


Data Structure Documentation

◆ LeftvDeep::copy_tag

struct LeftvDeep::copy_tag

Construct even deeper copy: Skip identifier (if any) and take care of the data on our own.

Definition at line 357 of file countedref.h.

Function Documentation

◆ countedref_init()

void countedref_init ( )
inline

Definition at line 458 of file countedref.h.

459{
462}
void countedref_reference_load()
Initialize blackbox types 'reference' and 'shared', or both.
Definition: countedref.cc:700
void countedref_shared_load()
Definition: countedref.cc:724

◆ countedref_reference_load()

void countedref_reference_load ( )

Initialize blackbox types 'reference' and 'shared', or both.

Definition at line 700 of file countedref.cc.

701{
702 int tok;
703 if (blackboxIsCmd("reference", tok) == ROOT_DECL)
704 return;
705
706 blackbox *bbx = (blackbox*)omAlloc0(sizeof(blackbox));
707 bbx->blackbox_CheckAssign = countedref_CheckAssign;
708 bbx->blackbox_destroy = countedref_destroy;
709 bbx->blackbox_String = countedref_String;
710 bbx->blackbox_Print = countedref_Print;
711 bbx->blackbox_Init = countedref_Init;
712 bbx->blackbox_Copy = countedref_Copy;
713 bbx->blackbox_Assign = countedref_Assign;
714 bbx->blackbox_Op1 = countedref_Op1;
715 bbx->blackbox_Op2 = countedref_Op2;
716 bbx->blackbox_Op3 = countedref_Op3;
717 bbx->blackbox_OpM = countedref_OpM;
718 bbx->blackbox_serialize = countedref_serialize;
719 bbx->blackbox_deserialize = countedref_deserialize;
720 bbx->data = omAlloc0(newstruct_desc_size());
721 setBlackboxStuff(bbx, "reference");
722}
int setBlackboxStuff(blackbox *bb, const char *n)
define a new type
Definition: blackbox.cc:142
int blackboxIsCmd(const char *n, int &tok)
used by scanner: returns ROOT_DECL for known types (and the type number in tok)
Definition: blackbox.cc:218
char * countedref_String(blackbox *, void *ptr)
blackbox support - convert to string representation
Definition: countedref.cc:363
BOOLEAN countedref_serialize(blackbox *, void *d, si_link f)
Definition: countedref.cc:679
void countedref_Print(blackbox *, void *ptr)
blackbox support - convert to string representation
Definition: countedref.cc:356
BOOLEAN countedref_deserialize(blackbox **, void **d, si_link f)
Definition: countedref.cc:691
BOOLEAN countedref_OpM(int op, leftv res, leftv args)
blackbox support - n-ary operations
Definition: countedref.cc:592
BOOLEAN countedref_Op3(int op, leftv res, leftv head, leftv arg1, leftv arg2)
blackbox support - ternary operations
Definition: countedref.cc:471
BOOLEAN countedref_Assign(leftv result, leftv arg)
blackbox support - assign element
Definition: countedref.cc:377
BOOLEAN countedref_Op2(int op, leftv res, leftv head, leftv arg)
Definition: countedref.cc:437
void * countedref_Init(blackbox *)
blackbox support - initialization
Definition: countedref.cc:186
void countedref_destroy(blackbox *, void *ptr)
blackbox support - destruction
Definition: countedref.cc:484
BOOLEAN countedref_Op1(int op, leftv res, leftv head)
blackbox support - unary operations
Definition: countedref.cc:406
BOOLEAN countedref_CheckAssign(blackbox *, leftv, leftv)
We use the function pointer as a marker of reference types for CountedRef::is_ref(leftv),...
Definition: countedref.cc:193
void * countedref_Copy(blackbox *, void *ptr)
blackbox support - copy element
Definition: countedref.cc:370
@ ROOT_DECL
Definition: grammar.cc:319
int newstruct_desc_size()
Definition: newstruct.cc:42
#define omAlloc0(size)
Definition: omAllocDecl.h:211

◆ countedref_shared_load()

void countedref_shared_load ( )

Definition at line 724 of file countedref.cc.

725{
726 int tok;
727 if (blackboxIsCmd("shared", tok) == ROOT_DECL)
728 return;
729
730 blackbox *bbxshared = (blackbox*)omAlloc0(sizeof(blackbox));
731 bbxshared->blackbox_String = countedref_String;
732 bbxshared->blackbox_Print = countedref_Print;
733 bbxshared->blackbox_Copy = countedref_Copy;
734 bbxshared->blackbox_Op3 = countedref_Op3;
735 bbxshared->blackbox_OpM = countedref_OpM;
736 bbxshared->blackbox_serialize = countedref_serialize;
737 bbxshared->blackbox_deserialize = countedref_deserialize;
738
739 bbxshared->blackbox_CheckAssign = countedref_CheckAssign;
740 bbxshared->blackbox_Assign = countedref_AssignShared;
741 bbxshared->blackbox_destroy = countedref_destroyShared;
742 bbxshared->blackbox_Op1 = countedref_Op1Shared;
743 bbxshared->blackbox_Op2 = countedref_Op2Shared;
744 bbxshared->blackbox_Init = countedref_InitShared;
745 bbxshared->data = omAlloc0(newstruct_desc_size());
746 setBlackboxStuff(bbxshared, "shared");
747}
BOOLEAN countedref_Op2Shared(int op, leftv res, leftv head, leftv arg)
blackbox support - binary operations
Definition: countedref.cc:576
void countedref_destroyShared(blackbox *, void *ptr)
blackbox support - destruction
Definition: countedref.cc:673
void * countedref_InitShared(blackbox *)
Blackbox support - generate initialized, but all-zero - shared data.
Definition: countedref.cc:540
BOOLEAN countedref_AssignShared(leftv result, leftv arg)
blackbox support - assign element
Definition: countedref.cc:648
BOOLEAN countedref_Op1Shared(int op, leftv res, leftv head)
Blackbox support - unary operation for shared data.
Definition: countedref.cc:546

◆ CountedRefPtr_kill()

template<class PtrType >
void CountedRefPtr_kill ( CountedRefIndirectPtr< PtrType > *  pval)
inline

Definition at line 151 of file countedref.h.

151{ delete pval; }