Changeset c8cb0d for src/Box.cpp


Ignore:
Timestamp:
Dec 26, 2025, 9:40:14 PM (6 weeks ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
Candidate_v1.7.1, stable
Children:
033646
Parents:
f2d5ce
git-author:
Frederik Heber <frederik.heber@…> (12/10/25 16:15:28)
git-committer:
Frederik Heber <frederik.heber@…> (12/26/25 21:40:14)
Message:

Streamlines channel creation in Observables.

  • CodePatterns is now version 1.3.4.
  • we no longer need to add the channels manually in the cstor of a class that derives from Observable. Instead, we just need to pass the maximum number of channels (as they are typically enumerated anyway) and they are generated and added.
  • added mutex protection when inserting.
  • adjusted class Relay to forward similar convenience cstors.
  • adjusted all call sites in molecuilder.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Box.cpp

    rf2d5ce rc8cb0d  
    5757
    5858Box::Box() :
    59     Observable("Box"),
     59    Observable("Box", NotificationType_MAX),
    6060    M(new RealSpaceMatrix()),
    6161    Minv(new RealSpaceMatrix())
     
    6565  index.reserve(NDIM);
    6666
    67   // observable stuff
    68   Channels *OurChannel = new Channels;
    69   Observable::insertNotificationChannel( std::make_pair(static_cast<Observable *>(this), OurChannel) );
    70   // add instance for each notification type
    71   for (size_t type = 0; type < NotificationType_MAX; ++type)
    72     OurChannel->addChannel(type);
    73 
    7467  M->setIdentity();
    7568  Minv->setIdentity();
     
    7770
    7871Box::Box(const Box& src) :
    79     Observable("Box"),
     72    Observable("Box", NotificationType_MAX),
    8073    conditions(src.conditions),
    8174    M(new RealSpaceMatrix(*src.M)),
     
    8578  coords.reserve(NDIM);
    8679  index.reserve(NDIM);
    87 
    88   // observable stuff
    89   Channels *OurChannel = new Channels;
    90   Observable::insertNotificationChannel( std::make_pair(static_cast<Observable *>(this), OurChannel) );
    91   // add instance for each notification type
    92   for (size_t type = 0; type < NotificationType_MAX; ++type)
    93     OurChannel->addChannel(type);
    9480}
    9581
    9682Box::Box(RealSpaceMatrix _M) :
    97     Observable("Box"),
     83    Observable("Box", NotificationType_MAX),
    9884    M(new RealSpaceMatrix(_M)),
    9985    Minv(new RealSpaceMatrix())
     
    10288  coords.reserve(NDIM);
    10389  index.reserve(NDIM);
    104 
    105   // observable stuff
    106   Channels *OurChannel = new Channels;
    107   Observable::insertNotificationChannel( std::make_pair(static_cast<Observable *>(this), OurChannel) );
    108   // add instance for each notification type
    109   for (size_t type = 0; type < NotificationType_MAX; ++type)
    110     OurChannel->addChannel(type);
    11190
    11291  ASSERT(M->determinant()!=0,"Matrix in Box construction was not invertible");
Note: See TracChangeset for help on using the changeset viewer.