Tumgik
#stuff which should be very quick like it doesnt need to be v detailed or specific i dont think like i can kinda just put it in willy nilly
zemnarihah · 1 year
Text
Tumblr media
here's the sketch btw:)
#in the final there's gonna probably be more stuff in the background just whatever random stuff like more jars and bottles and books it just#felt silly to spend time drawing that rn when i'm going to have to transfer it#but anyway YEAH i'm having a lot of fun on this one:)#i rlly like the fairies i originally had them like trapped#they're going to be light sources like they act as lanterns in the jars#so originally they were just trapped in there but i was like. man:/ that's not cool...#and i wanted them to be more like. playful or whatever so i gave them a way in and out and stuff and had them be kinda gossipy#bc i think that's fun:) in my brain they like live w her and give her light and help her w miscellaneous magic stuff and she gives them a#nice cozy place to live but they're still silly mischievous little guys....#ANYWAY#yeah so the plan tomorrow. i have to go to the school to use a light table and transfer it. and then i should probably also go get a new#pen bc my fine one is running out. AND THEN idk maybe i should do a value study or smth and also finish drawingthe rest of the miscellaneou#stuff which should be very quick like it doesnt need to be v detailed or specific i dont think like i can kinda just put it in willy nilly#and then after that we watercolor!#doing that FIRST this time#and i think i'm just gonna do monochrome bc ummm i don't have time. so that should go quick bc i dont want to do it super detailed or#anything just flat washes for value n such#like maybe a kinda foresty green....#and then we line it! which is the fun part:)#sorry nobody cares abt that but i have to write it out#just for my own self to know. what the FUCK is going on.#i'm rlly hoping i can finish it tmrw but who's to say. i have the whole day but it depends on how focused i can stay idk#ok im going to bed now. goodnight. if anyone actually read all that.#my art
6 notes · View notes
miaxeu · 4 years
Text
      though the mist might prevent some from seeing it, MIA STOEGER is actually a descendent of DIONYSUS. it’s still a question of whether or not the TWENTY-ONE year old MYTHOLOGICAL STUDIES MAJOR from LOS ANGELES, USA has taken after HER godly parent completely, but the demigod is still known to be quite CHARISMATIC & DUPLICITOUS. 
Tumblr media
( y’all dont deserve this real messy intro but im workin w half a bwain cell at 4am so i beg thee 4 mercy. nywyy im the excited new girl who’s hella pumped to meet all ur charas : katya ! feel free to hop in my ims to plot or drop a like and i’ll hop in urs ! x  )
POWERS
natural acting abilities — her ma’s a hollywoo agent so she started actin real early & now shes a big shot actress. there r more deetz on her career below !
chlorokinesis — it wasnt as natural as acting n she only started working on it when she turned 13 n started going to camps. b4 she just noticed shes good w plants but it wasnt super crazy or nything. its p good now tho ! shes prioritizing vine binding and manipulation 4 the self defense bc awards r cool n all but they dont rlly protecc from monsters ykwim 
levitation — shes trying her best ur honor
alcokinesis  — she cant conjure it or anything, she’s just immune to it ffff
BIO POINTS — cw: drug use ( full biography here )
her mom raised her by herself bc dionysus the party god was out of the picture immediately. she never told mia she’s a demigod & it was always just “ wow ur so talented ” or “ aww u got a green thumb ! ” but when she saw him claim 13 y/o mia by placing a weird hologram over her head while she slept, she knew she had to spill da beanz & tell her kid
ofc mia thought her mom was jus playing sum weird acting exercise w her bc her powers r so lowkey she could highkey just be a Mortal but insert sad whistle, the realizashun & the claiming meant heightened monster threat !! so yea ,,, one ended up chasing her a couple days later rip 
aside from the trauma, mia was ok. mostly bc she ended up cryin for dionysus like any child would n lo & behold he came & helped !!! as he should. nywy she made sure to go to summer camps every year after that but mostly just for protection purposes
she lowkey rlly hates this whole god business esp now that shes grown lmfao deadass thinks she got a bad deal bc life threats arent sexy !!! went to eonia eventually bc its Too Much Man. she just wants to go back to work and her life w the mortals w/o worryin for her life. would deadass fade her father if she could. may or may not be majoring in greek mythology to figure out the logistics of it all out of spite, who knows !
PERSONALITY
not ! a Drama Queen  —  dont get me wrong, shes hella Extra in the way she moves n acts sorta like shes always bein captured on film. is quick-witted & playful & can be a huge tease/flirt if she feels like it, but miss her w Real Feelings ! totally not sentimental. srsly she will try to rationalize away everything and is just,.,., not good w it. so soz folks, we just keepin it breezy here
ugh, she’s an Actress — aka she can act like she cares tho ! shes very much into keeping ppl on her good side. shes friendly n palatable to everyone bc its how shes been trained & while it doesnt seem fake, its def diff when its genuine
The Mortifying Ordeal of Being Known —  lemme circle back to the first one, ok so shes good w emotions but only in theory. does intense character work with her roles so she thinks that counts as her having eq when rlly shes just emotionally stunted, projecting n repressing like an idiot
blonde, skinny, rich, & a lil bit of a Bitch — shes only a bitch inwardly or to ppl she trusts enuff to let in on the gossip. if anyone full on opposes her or becomes real emotional, then this lil diva will rear its superiority complex head n snap a lil. will most probably do it v underhandedly n w a smile but it will be Brutal
girls just wanna have FUN ! — shes the child of da party god, so ofc she a true party girl. officially off the rails when she parties. inhibitions ? we dk her. can be insensitive in that case bc smtms its truly no strings attached, tis all abt the fun. likes company a lot & it doesnt even have 2 be loud or particularly abt her, she just likes having people around n the escapism of it all. will make friends with everyone n make sure they have a jolly fun time guaranteed at dionysus parties 
Work Hard, Play Hard — real responsible when it comes to work and commitments and if she trusts/likes u enough, she’ll give it 2 u straight, no bs. def thinks Calling Out is an act of love but maybe does it a lil too harshly smtms. v much into efficiency, sentiments be damned. not the feely words type. will sit next to u or party w u or even pay 4 ur therapist if u need sum1 to talk to. she will Be There while u work thru it, so long as u dont expect her to change n be all emotional n stuff
if she seems a lil contradictory thats bc she kinda is. tis the good ol nurture vs nature. her ma’s a real no nonsense chick n her pops is a frat guy drama geek greek god whos rlly into cottagecore so u get this lil blonde bitch whos sorta teetering on the edges
OTHER INFO  — cw: drug use ( full headcanons here )
re her career, she achieved pegot status when she was 18 aka she truly b dat bitch. shes not super mainstream famous tho, more like indie sweetheart, film snobs/critics fave typa gal. if ya want a trajectory she started w baby commercials then a sitcom from 4-10 ( think modern fam’s lily ) then it was off to the big screen & the stage ! 
mia has a lil bit of a drug habit. its not abusive or dependent, but it is a staple whenever shes parties bc alcohol is useless 2 her. started a lil young too bc hollywoo. primarily uppers/hallucinogens. she smokes weed a lil more liberally but the rest is mostly just an on occasion thing ( which, ngl, is a still a lil problematic when u party a lot rip )
after she got claimed, mia ended up going to demigod camps in a lot of diff places n countries, depending on where production would take her. there was never an established place, more like wherever was nearest when they wrapped up shooting bc monsters afoot n wutnot  
she was always homeschooled but she still managed to go to a prom and homecoming bc party is life. that makes eonia uni p much her first chance at having a normal educational environment & experience and even then its anything but. still tho this is her moment !!! im lit rally begging her to get a personality that isnt her internally rolling her eyes going “ its not that deep ”
might put up a bio/stats page if im feelin sxc but i wud jus like the records to show that mia stoeger is a bi sxc babe bc me ? write a het ? no grassy ass.
POSSIBLE CONNECTIONS — cw: drug use ( full connections here )
omg danny devito i love ur work ! 
,,, p self explanatory sdkjfs sum1 who loves her work ! it can be lowkey/highkey fangirl to a civil admiration
OR alternatively, y/m can Not Be a fan of her work. they might think the storyline of the projects she takes on r too out of touch n highbrow yada yada yada, but yes, we love to see either of it ! 
summer camp sweetheart !  
someone she met when at camp when they were teens ? doesnt matter in what country/city, but mia was only visiting so it was truly a one summer romance typa thing. bc she was younger, im thinkin 13-17 or w/e she was probably sweeter n a lot more emotional then. was it either’s first puppy love ? first kiss ? first “ relationship ? ” idk, do yk ? truly, so many possibilities. nothin set in stone just hmu bub 
summer camp pals ! 
p much the same as above but make it Platonic
party buddies !
or druggie pals. either way works but she wud luv it if theyre both xoxo
friends w benefits !
most probably ( but not limited to ) sum1 she met at a party skdjhsjk is it exclusive ? is any1 starting to develop feelings ? im down 4 nthing n evrything
alexa play true friend by hannah montana !
give mia her college bestie ! her confidant who knows her feels and can call each other out viciously with no ounce of resentment. we stan the friendships !
omg i love ur skirt !
that is the ugliest effing skirt i've ever seen. lmao basically sum1 mia pretends to like or acts civil w but rlly ,,,, Cannot Stand for w/e rzn   
im p much braindead rn but those are just sum ideas !!! ofc the usual staples like the pals, enemies, wutnots are also v welcome we love to see it. if u also have a wc that u think mia would fit in, id luv to know more ! there are also a couple more detailed ones here, but pls feel free to shoot me a msg n we can get 2 plotting x 
( * wipes brow * how did i type so much n say so little rip. mia is also a completely new muse so pls b patient n if i fuq up from time to time, pretend u do not see >.< nywy thnx 4 readin, sweets ! feel free to hmu here or at discord if ya wanna <3333 )
FULL INFO  ||  EONIA TASKS 
20 notes · View notes
blahrutocs · 7 years
Photo
Tumblr media Tumblr media
i redesigned casey and now i kinda ship him w/ sal..... i’ve been Developing him a bit too and this is what ive come up w,
sal and casey would be a cute couple imo.... they'd probably butt heads at first, bc casey butts heads with Everyone at first by nature, and he's really argumentative naturally whereas sal is kind of Nervous around new people, but like... sal can find the good in anyone, which is somethin' i think casey would need, because he's not good at expressing the good in himself!!then they probably found some middle ground......... sal has a very calming presence, i think, he's a very Sweet person and people like being around him a lot........ but he'd definitely be someone who wouldn't judge him or say anything cruel, he always puts a lot of time and consideration into the people around him and i think that'd be something very good for my boy, cause then he could also just....Develop a good and nice friendship with sal!! they probably became real close real quick and it....confused everyone, i bet!! casey probably gets frustrated sal doesn't tend to Value himself as much as he should and doesn't really stand up for himself. i feel like casey is.....Very Open about finding Sal attractive but just not in front of sal, like he's casually just like "hey, how is that man single when he looks like a literal god, jw. askin for a friend" and everyone in the groups like..........hey man do u wanna date sal? kinda sounds like you wanna date sal,
Casey is secretive to No One, except for Sal...................whenever Sal is around he clams up! He ain't gonna say nothing gay in front of that boy (who he would totally smooch if he offered tbh) i picture casey being like, that one kid w/ no friends who watches anime and decides he's gonna learn japanese........
Casey draws Anime in his sketch book which he shows to no one except friends, and also hates being asked to draw someone because he thinks its totally uncool (he'd probably draw sal if he asked though) he's probably pretty good by now since.......Not havin friends gives you time to work on stuff!! I think he'd be interested in animation to some extent, too!! casey is also a photographer and has a degree in filmaking....I Imagine him RLY wanting to take pics of sal but being too shy to ask, also he puts timers so he doesn't like sal's selfies too quickly bc he Doesn't Want to Look TOO gay. he probably flirts with sal a bit but makes sure it's mild and sounds like a joke!! sal has.......No Idea, honestly, he's just like.....Totally clueless to it, I mostly picture sal as having........ Self esteem Resembling a rollercoaster and sometimes he'll be like "YES I AM GOOD AND PEOPLE LIKE ME" other times he's like "me? i am a garbage rat and i come from the sewers, my truest home," so has a hard time really Believing people like him, For Some Reason, casey probably lowkey wants to confess but doesn't know how, he's also probably mildly terrified he's gonna make sal uncomfortable bc he really values the friendship and.....Doesnt wanna Gay It Up if it's not needed,  i kind of think casey's probably had a few friendships that...........Didn't pan out, bc they found out he was gay and got very Weird about it, and he probably tries to......Not Replicate that, despite sal being Very considerate..... he singlehandedly organized a gsa in highschool and then also planned their Queer Prom almost Completely by himself...........  he's like, the last person in the world who would be unkind to casey about something like that!! 
  Casey is just a nervous boy who often worries about being Accepted, even by other Very Gay folks...........he's probably a lil nervous about like, intimacy and stuff. doesn't like being touched without being explictly asked.......
he had a casual relationship with riley but riley is.............Very chill, so i think it wouldn't be too unpleasant for him.............. casey probably doesn't like not being the one in control though!! it works out bc sal is kind of uncomfy w/ sex in general and demisexual......... he's not adverse to it but it does make hm nervous!!   
he animates sometimes in his freetime, i think, he has.......Lots of free time, lbr, his  parents are both like...... Doctors, so he doesn't worry that much about Money or anything! and tries to fill his spare time with...... Whatever, really, he pobably has a few weird skills he never talks about,
mitch was probably casey's first real friend... he and riley didn't know eachother very well by the time riley dropped out, but he and mitch both stayed and finished college, so they probably became pretty good friends!! mitch stayed in touch with riley, so by extension so did casey. otherwise casey probably would've been too insecure to put any effort into the connection.
he’s kind of typically “flamboyant.” snarky. will not take any shit. he’s a photographer, he has a degree in filmmaking and enjoys it a lot. very secretive, doesn’t really share any personal details with people. pretty judgemental. will comment on your outfit if he thinks it’s bad or like… straight up laugh at your opinion sometimes. he can win arguments but……Often Unintentionally hurts feelings doin so!!
he secretly likes people more than he lets on he’s just….Super bad at socializing because he’s like inherently argumentative and cant turn it off. he was also not a popular kid, he moved to a new town and was really chubby  and people were just… not nice to him. he was v self conscious ab it!! hes Very New to friendships!! his first real friend was when he was an adult already.  he’s got a lot of softness inside of him!! 
OTHER FACTS...........
*casey self harms, he’s not proud of it but doesn’t hide it either.......
*he’s been diagnosed w/ adhd and anxiety but...... Does Not Believe He has either of those things
*constantly on the defense
*doesn’t have a good relationship w/ his parents but..........Doesn’t really bother fighting w/ them, they’re not the nicest but he just.Gnuinely doesnt care anymore.
* he and sanchez dont have the best relationship,casey’s theory is its bc he used to be fwbs with riley and Was Not at all subtle about it but like…. when he first meets sanchez he comments how he thought he’d be taller, and then immediately follows it up with “Btw, i fucked your bf.”
i’ll add more to this later................. also if anyone read this whole thing what would be a good ship name for them cause i got,.......No clue
2 notes · View notes
thothonegan · 7 years
Text
Coding Conventions
I've had a few people ask how I layout my code. So here's a quick overview. Of course coding conventions is a very touchy topic for a lot of programmers, so don't take this as the 'best' approach or anything. It's just what works for me. A lot of it has been inspired by various other guides such as the Google C++ Style Guide so look at those too.
Files
Naming Conventions
Rule: .cpp for C++ source files, .hpp for C++ header files.
Justification: Mostly makes it obvious what a file is written in. If you've ever included a C file without extern C and it didnt support c++ correctly, you know why this is useful.
General Indentation
Rule: Tabs for indentation, spaces for alignment.
Justification: This is probably the number one things programmers argue about. Personally, I find the benefit of having a specific alignment character nicer then not. And I hate typing lots of spaces in code (python) that requires it (or YAML : even if my editor is setup for tab=spaces, it always puts the cursor in the wrong place). Or even this stupid markdown editor because Tumblr doesnt understand triple grave code blocks properly *kicks*.
Header Guards
Rule: Use old style C #define header guards, generally named from the project down (like WOLFCORE_THREAD_HPP ).
Justification: I know some people prefer #pragma once and it's supported practically everywhere, but it's still non-standard. This is mostly a 'I'm used to it' type thing, and theirs a few cases where its useful. Like for example, you want to guarantee a certain file was included before you (like the hell that is Windows.h).
Forward declarations
Rule: Prefer forward declarations for classes to using includes.
Justification: This is something I never cared about till my compile times increased due to how big my projects have gotten. C++ also has a lot of constructs (templates, inlines) which require headers to be included so its best to give it as much of a help as possible. When modules becomes standardized, hopefully it'll help with this.
Documentation
Rule: Everything in headers should be documented. In source files, just readable comments are needed.
Justfication: For me, header files are like the index of a book. The main reason I'm looking through them is for an API I need, or need to learn how to use a class. Having everything documented and neatly sectioned makes this easy (especially when combined with doxygen). I definitely document more than most people do, but its come in handy too many times to count when coming back to a class I wrote years before and completely forgot the quirks a class has.
The one other related big rule is if something happens such as a crash due to using an API wrong, the documentation for that function must have pointed that out. If it did, I as a user of the function was wrong : if it doesn't, that's a bug in the function (either it should point it out, or the function needs to be fixed). This rule alone has improved stability of my programs, because just making it not crash anymore doesn't mean its actually fixed. And if its possible for the function to detect that condition (in debug mode) and abort, it is required to. If you can get every crash down to where the app detects it before the system does, that is huge. Its much nicer to get a 'Abort: Tried to access a null pointer here [backtrace]' instead of 'SIGSEGV'.
Naming Conventions
Macros
Rule: Macros will be named in all capitals. WOLF_APPLICATION() for example.
Justification: This keeps the preprocessor neatly seperated from the rest of the language. Anything in all caps or with #stuff you know happens before the compiler runs.
Constants
Rule: Constants will be CapitalCamelCase. Note this generally only applies to full constants, and not just variables marked 'const'.
Justifcation: With variables being different, this makes it easy to tell if something's designed to be assignable or not.
Variables
Rule: Variables will be lowerCamelCase (with the exceptions of prefixes). Variable names can have a prefix of '[letters]_[name]' if they fall into specific categories. Namely:
m : A member variable
s : A static variable (usually file scope)
A variable might also have postfix names too, though thats mostly up to the module. Common ones are S for seconds (durationS), str for string (durationStr) and so on.
Justfication: The lowerCamelCase is basically to counter with constants, so at a glance you can tell the basics of a type. With the prefixes, you also know the scope of a variable and cannot easily get confused between local variables and long living variables like members. The final part about prefixes is a form of Application Hungarian Notation (not to be confused with Systems Hungarian (ala lpCmdLine) which is what Windows uses and is annoying to work with).
Namespaces/Classes/Structs/Enums/Unions
Rule: Containers will use CapitalCamelCase, very much like constants. Add 'Private' somewhere to the name if its for internal use.
Justfication: Mostly distinctiveness again. The mixing between constants and containers also generally isnt a problem, and the compiler will point it out if you accidently use one at the other.
Functions/Methods
Rule: Functions/Methods will use lowerCamelCase with one of the prefixes below if required. Generally functions if they return a value should have the return as part of the name (aka do not do val = calculate(), instead val = calculateLength()). Setters start with set while get just name the value. Prefixes used include:
p : Protected/Private function - not callable outside the class and/or decendents.
i : Internal function - might be public, but isn't part of the common/normal interface. Be careful!
s : Static function - limited to the file. Note that this ISNT used for class static functions (since they are public interface).
v : Virtual function. See Private Virtuals below for more details. Not public generally.
r : CRTP function. Called by one of the classes we inherit from. Not public.
Justification: The difference from other constants makes it easier to deal names. You can tell instantly that WolfCore::Module is some form of container, while WolfCore::Module::v_init is a virtual function. The mixing with variables isn't an issue since they are never valid in the same contexts.
The setter/getter thing is mostly a question of style. The goal is to make public usage as straightforward as possible, and allow information hiding as easily as possible (since it costs 0 due to inlining). With the member variable rule above, this then means you have something like:
m_value : The member variable 'value' which stores the value.
value() : A function to retreieve the member variable 'value'.
setValue(Type&) : A function to set the member variable 'value'.
And now probably the most distinct thing in my style: the function prefixes. Anything off the normal public path has a prefix, which allows devs to know the category of a function without affecting users of the class. I'll explain each rule individually, and justify them seperately.
p_function() : Protected/Private functions. These are functions the normal user shouldnt ever care about, so theirs no reason it should come up in code-completion/etc. When using certain APIs, I've tried to call a function only to realize it was private, and was just part of the code because of how classes work. While IDEs try to show them differently, a little icon change isn't easily noticable. This makes it a lot more obvious. There is no distinction between protected/private because I default everything to private, and the few cases you use protected, you know what you're doing (since you're working on the backend of the class).
i_function() : 'Internal' public functions. There is a few cases where you need a function to be public that really shouldn't be - but for some reason friend wont solve it, or makes an even bigger mess. Internal functions allow you to public something, yet its still not a 'normal' function. If you ever see a call to one of these, its a big warning sign that its doing something odd. An example in Wolf is Matrix::i_fromEigenMatrix() : nothing in Wolf publically should depend on my matrix implementation being eigen, yet its needed for some of the helper classes to be able to easily pass things around.
s_function() : Static per file functions. This is mostly used for private helper functions for classes which arent part of the public interface. Mostly they'll end up in an anonymous namespace. Things like s_initKeyboardTable() in various window drivers that just setup a global table for looking up keyboard keys. Note this is not used for static class functions. Those use normal naming conventions (like Manager::manager()).
v_function() : This is Private Virtuals. More details at the end, but it is a way to seperate virtual implementations from the actual calling interface. You almost never call a v_function() directly, but it marks the interface a parent class might call you with.
r_function() : CRTP. If you don't need the runtime calling abilities that virtuals provide, CRTP allows you to require a specific interface thats completely resolved at compile time (mostly at 0 cost due to inling). From a code writer perspective, its the same as a virtual v_function(). Might write a blog post about CRTP someday, cause it's a handy technique that a lot of people don't know about.
All of these are cases where you're either limited where you can call it, or you need to be careful when you're calling it. Having these special function prefixes have helped me a lot.
Indentation/Spacing Rules
This is more of the 'feel good' type rules. Can't really justify most of them other then its just how I do things.
Tabs (Literal tab character, editor view set to 4 spaces)
Mostly Allman style in formatting. I've experimented a bit with others such as 1TBS, but while Allman loses a bit in density its pretty nice to read.
Spaces arround operators, keywords, etc
I do allow single statement constructs such as if, but been trying to get away with a condensed Allman for those cases.
Example:
if (condition) { break; }
instead of
if (condition) break;
Spaces after function names.
Namespaces use Allman, but if multiple namespace are grouped together, I use one line. I don't need this as much as I used to, but this probably the number one thing that editors despise me doing (they keep trying to fix it). This is mostly to prevent indentation explosion.
Example:
namespace Wolf { namespace Core { class A; } }
C++17 will add namespace Wolf::Core which will help.
Decorations on variables go with the types: aka const Type* t. Yes I know if you're abusing C this looks weird (the char* a, b example) but the answer is to stop abusing C. Yes its technically part of the variable not the value, yes its 'how you use it' and 'not part of its type' but it acts like part of the type, thus its part of the type. Ducks quack and all. Speaking of...
One declaration per line. End of story. No char* a, b crap. If you have a ton of variables to generate, use preprocessor macros or a supporting tool.
Dont use void in the parameter list. I used to, and a lot of code of mine still does, but blank is just fine. Unless you're in C of course, cause C defaults to int for some reason.
Prefer using to typedef. C++11 made it way more powerful, and its more readable too.
A quick example of everything put together, WolfThread::Thread's header! (some parts removed for space).
namespace WolfThread { // /// \brief A class that represents a thread of execution /// /// Subclass Constructor must have the format: /// explicit Thread (ThreadFunctionPointer f); // class Thread { public: /// \name Types /// \{ // /// \brief Function prototype for threads // using FunctionPointer = WolfType::Function<void (WolfThread::Thread* thread)>; /// \} /// \name Construction/Destruction /// \{ // /// \brief Destroy the thread - will join if joinable // virtual ~Thread () {} /// \} /// \name Joining/Detaching /// \{ // /// \brief Join the thread - waits for it to finish its execution // void join () { v_join(); } // /// \brief Detach the thread - the thread is now independent of this handle // void detach () { v_detach(); } /// \} WOLF_DEFAULT_MOVE(Thread); WOLF_DEFAULT_ASSIGN_MOVE(Thread); WOLF_DISABLE_COPY (Thread); WOLF_DISABLE_ASSIGN (Thread); protected /*child interface */: // /// \brief The thread is starting. Should be called by children when the thread started. // void p_threadStarted (); // /// \brief The thread is exiting. Cleans up runloop/etc : should be called by children classes when the thread is about to return. // void p_threadExiting (); private: /* child interface*/ // /// \brief Join the thread - waits for it to finish its execution // virtual void v_join () = 0; // /// \brief Detach the thread - the thread is now independent of this handle // virtual void v_detach () = 0; }; }
Private Virtuals
So a quick aside about virtuals. Virtual functions are pretty amazing, but theirs a few issues with using them:
Interface and Implementation are mixed. The caller of the function is tied directly to the implementation.
Not able to easily insert your own code. Want code to run before and after every call? Can't really do it, without assuming that your child classes will call back to you. Speaking of..
Can't guarantee what child classes will do. Will they call you before they do things? After?
What if later on you want the interface to change? All the callers and the callees have to change. Even if its mostly compatible.
If you have behavior in your parent class, you can't guarantee you're overridden. Modern C++ added support for having default behavior yet being pure, but its still odd.
So the C++ STL (among other places) has an interesting way to fix these. Instead of having one function (say init() that is both called and overridden) you instead have two:
public: void init () { v_init(); } // calls the virtual - public interface private: virtual void v_init () = 0; // child HAS to override [or not if you dont make it pure]
Even though its private, you can override it from a child class. They just cant call the base version (since its private). So what does this gain us?
Interface and Implementation are seperate. The implementation only messes with the v_init() one, and doesnt know/care if init() is the only caller of it.
Since the interface is seperate, we can easily add any code we want before/after the v_init() all. None of the callers have to change, because its all filtering through init.
We still can't guarantee what child classes will do, but thats fine because they cant call the parent function anyways! So we can guarantee we can do things before/after them regardless of what they do.
If you want to change the interface or the implementation, go right ahead. Only the callers or callees will need to change as long as you keep them compatible. You can even have multiple virtual interfaces and the public API choose whichever it wants.
You can have behavior in your parent class, yet your function is still pure virtual and must be overriden (since its not part of the implementation function).
And yes, at least for simple cases like this it's 0 cost - C++ will inline it all anyways.
The one downside you get is that you have to duplicate your functions - for every virtual, you need the public interface function too. Not a huge deal while you're building things. And if you document all interfaces like I do, it costs a bit more time there too.
This takes some time to get used to, but it comes in handy.
Ending
Wow, that turned out to be a lot more than I expected - and I bet I missed a lot of things. Anyways, thats a basic look in my code formatting - I still tweak things here and there, and theirs definitely places in my codebase with older styles. The most important thing though is having a style - because even if its different (unreal and its 'everything is capitalized' for example), as long as its consistent its fine working with.
0 notes